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 — buffer: allow .write() offset to be at buffer end · nodejs/node@e371545

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_buffer.cc
  • test/parallel
    • test-buffer-alloc.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_buffer.cc‎

Copy file name to clipboardExpand all lines: src/node_buffer.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ void StringWrite(const FunctionCallbackInfo<Value>& args) {
714714
size_t max_length;
715715

716716
CHECK_NOT_OOB(ParseArrayIndex(args[1], 0, &offset));
717-
if (offset >= ts_obj_length)
717+
if (offset > ts_obj_length)
718718
return env->ThrowRangeError("Offset is out of bounds");
719719

720720
CHECK_NOT_OOB(ParseArrayIndex(args[2], ts_obj_length - offset, &max_length));
Collapse file

‎test/parallel/test-buffer-alloc.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-alloc.js
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ writeTest.write('e', 3, 'ascii');
358358
writeTest.write('j', 4, 'ascii');
359359
assert.equal(writeTest.toString(), 'nodejs');
360360

361+
// Offset points to the end of the buffer
362+
// (see https://github.com/nodejs/node/issues/8127).
363+
assert.doesNotThrow(() => {
364+
Buffer.alloc(1).write('', 1, 0);
365+
});
366+
361367
// ASCII slice test
362368
{
363369
const asciiString = 'hello world';

0 commit comments

Comments
0 (0)
You are visitor 01402520 — 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.