mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 22:31:35 +00:00
fs: add validateBuffer to improve error
PR-URL: https://github.com/nodejs/node/pull/44769 Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
8ec7bfd9c5
commit
bb4891d8d4
@ -632,7 +632,7 @@ function read(fd, buffer, offsetOrOptions, length, position, callback) {
|
||||
}
|
||||
({
|
||||
offset = 0,
|
||||
length = buffer.byteLength - offset,
|
||||
length = buffer?.byteLength - offset,
|
||||
position = null,
|
||||
} = params ?? kEmptyObject);
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ assert.throws(
|
||||
|
||||
assert.throws(
|
||||
() => fs.read(fd, { buffer: null }, common.mustNotCall()),
|
||||
/TypeError: Cannot read properties of null \(reading 'byteLength'\)/,
|
||||
{ code: 'ERR_INVALID_ARG_TYPE' },
|
||||
'throws when options.buffer is null'
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user