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 — src: change Fill() to use ParseArrayIndex() · e7dal/node@d4660ab

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_buffer.cc
  • test/parallel
    • test-buffer-fill.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
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,11 @@ void Fill(const FunctionCallbackInfo<Value>& args) {
590590
THROW_AND_RETURN_UNLESS_BUFFER(env, args[0]);
591591
SPREAD_BUFFER_ARG(args[0], ts_obj);
592592

593-
uint32_t start;
594-
if (!args[2]->Uint32Value(ctx).To(&start)) return;
595-
uint32_t end;
596-
if (!args[3]->Uint32Value(ctx).To(&end)) return;
593+
size_t start;
594+
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[2], 0, &start));
595+
size_t end;
596+
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[3], 0, &end));
597+
597598
size_t fill_length = end - start;
598599
Local<String> str_obj;
599600
size_t str_length;
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-buffer-fill.js
+12-8Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,12 @@ Buffer.alloc(8, '');
325325
assert.strictEqual(buf.toString(), 'էէէէէ');
326326
}
327327

328-
// Testing process.binding. Make sure "start" is properly checked for -1 wrap
329-
// around.
330-
assert.strictEqual(
331-
internalBinding('buffer').fill(Buffer.alloc(1), 1, -1, 0, 1), -2);
328+
// Testing process.binding. Make sure "start" is properly checked for range
329+
// errors.
330+
assert.throws(
331+
() => { internalBinding('buffer').fill(Buffer.alloc(1), 1, -1, 0, 1); },
332+
{ code: 'ERR_OUT_OF_RANGE' }
333+
);
332334

333335
// Make sure "end" is properly checked, even if it's magically mangled using
334336
// Symbol.toPrimitive.
@@ -347,10 +349,12 @@ assert.strictEqual(
347349
});
348350
}
349351

350-
// Testing process.binding. Make sure "end" is properly checked for -1 wrap
351-
// around.
352-
assert.strictEqual(
353-
internalBinding('buffer').fill(Buffer.alloc(1), 1, 1, -2, 1), -2);
352+
// Testing process.binding. Make sure "end" is properly checked for range
353+
// errors.
354+
assert.throws(
355+
() => { internalBinding('buffer').fill(Buffer.alloc(1), 1, 1, -2, 1); },
356+
{ code: 'ERR_OUT_OF_RANGE' }
357+
);
354358

355359
// Test that bypassing 'length' won't cause an abort.
356360
assert.throws(() => {

0 commit comments

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