GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: fix fs.read when passing null value · nodejs/node@b8b8e82

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • fs.js
  • test/parallel
    • test-fs-read.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/fs.js‎

Copy file name to clipboardExpand all lines: lib/fs.js
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,12 @@ function read(fd, buffer, offset, length, position, callback) {
485485
callback = offset;
486486
}
487487

488-
buffer = options.buffer || Buffer.alloc(16384);
489-
offset = options.offset || 0;
490-
length = options.length || buffer.length;
491-
position = options.position;
488+
({
489+
buffer = Buffer.alloc(16384),
490+
offset = 0,
491+
length = buffer.length,
492+
position
493+
} = options);
492494
}
493495

494496
validateBuffer(buffer);
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-fs-read.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ assert.throws(
8080
}
8181
);
8282

83+
['buffer', 'offset', 'length'].forEach((option) =>
84+
assert.throws(
85+
() => fs.read(fd, {
86+
[option]: null
87+
}),
88+
`not throws when options.${option} is null`
89+
));
90+
8391
assert.throws(
8492
() => fs.read(null, Buffer.alloc(1), 0, 1, 0),
8593
{

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.