mirror of
https://github.com/nodejs/node.git
synced 2025-08-16 14:18:44 +02: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
2 changed files with 2 additions and 2 deletions
|
@ -632,7 +632,7 @@ function read(fd, buffer, offsetOrOptions, length, position, callback) {
|
||||||
}
|
}
|
||||||
({
|
({
|
||||||
offset = 0,
|
offset = 0,
|
||||||
length = buffer.byteLength - offset,
|
length = buffer?.byteLength - offset,
|
||||||
position = null,
|
position = null,
|
||||||
} = params ?? kEmptyObject);
|
} = params ?? kEmptyObject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ assert.throws(
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => fs.read(fd, { buffer: null }, common.mustNotCall()),
|
() => 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'
|
'throws when options.buffer is null'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue