diff --git a/src/node_internals.h b/src/node_internals.h index efdc82e531fe82..485ba18b3c742e 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -169,7 +169,7 @@ inline MUST_USE_RESULT bool ParseArrayIndex(v8::Local arg, return true; } - int32_t tmp_i = arg->Uint32Value(); + int64_t tmp_i = arg->IntegerValue(); if (tmp_i < 0) return false; diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js index b88b12f7f67526..733fa105043c1c 100644 --- a/test/parallel/test-buffer-alloc.js +++ b/test/parallel/test-buffer-alloc.js @@ -1440,3 +1440,9 @@ assert.equal(Buffer.prototype.parent, undefined); assert.equal(Buffer.prototype.offset, undefined); assert.equal(SlowBuffer.prototype.parent, undefined); assert.equal(SlowBuffer.prototype.offset, undefined); + + +// Test that ParseArrayIndex handles full uint32 +assert.throws(function() { + Buffer.from(new ArrayBuffer(0), -1 >>> 0); +}, /RangeError: 'offset' is out of bounds/);