diff options
author | Trevor Norris <trev.norris@gmail.com> | 2016-04-06 16:04:40 -0600 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2016-04-08 10:59:00 -0600 |
commit | 9d94cc584e50066150b4d2819eb3e7657a0edb4a (patch) | |
tree | 54b3b3ef24483cd00b98000db6c21374433c06e2 /test | |
parent | 945454894bf191e3d1753647fa2d574f4692f5e3 (diff) | |
download | android-node-v8-9d94cc584e50066150b4d2819eb3e7657a0edb4a.tar.gz android-node-v8-9d94cc584e50066150b4d2819eb3e7657a0edb4a.tar.bz2 android-node-v8-9d94cc584e50066150b4d2819eb3e7657a0edb4a.zip |
buffer: standardize array index check
ParseArrayIndex() was requesting a Uint32Value(), but assigning it to an
in32_t. This caused slight differences in error message reported in edge
cases of argument parsing. Fixed by getting the IntegerValue() before
checking if the value is < 0. Added test of API that was affected.
PR-URL: https://github.com/nodejs/node/pull/6084
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-buffer-alloc.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js index b88b12f7f6..733fa10504 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/); |