Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bb4891d

Browse filesBrowse files
author
Hirotaka Tagawa / wafuwafu13
authored
fs: add validateBuffer to improve error
PR-URL: #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>
1 parent 8ec7bfd commit bb4891d
Copy full SHA for bb4891d

File tree

Expand file treeCollapse file tree

2 files changed

+2
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+2
-2
lines changed
Open diff view settings
Collapse file

‎lib/fs.js‎

Copy file name to clipboardExpand all lines: lib/fs.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ function read(fd, buffer, offsetOrOptions, length, position, callback) {
632632
}
633633
({
634634
offset = 0,
635-
length = buffer.byteLength - offset,
635+
length = buffer?.byteLength - offset,
636636
position = null,
637637
} = params ?? kEmptyObject);
638638
}
Collapse file

‎test/parallel/test-fs-read.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-read.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ assert.throws(
7979

8080
assert.throws(
8181
() => fs.read(fd, { buffer: null }, common.mustNotCall()),
82-
/TypeError: Cannot read properties of null \(reading 'byteLength'\)/,
82+
{ code: 'ERR_INVALID_ARG_TYPE' },
8383
'throws when options.buffer is null'
8484
);
8585

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.