From: Volker Mische Date: Fri, 19 Jan 2018 14:49:22 +0000 (+0100) Subject: Out of bounds error message changed X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=66ae1aef42e5475a258a3471bc732ba61b85c2ef;p=buffer.git Out of bounds error message changed --- diff --git a/index.js b/index.js index 9481755..0ee40c1 100644 --- a/index.js +++ b/index.js @@ -1462,7 +1462,7 @@ Buffer.prototype.copy = function copy (target, targetStart, start, end) { if (targetStart < 0) { throw new RangeError('targetStart out of bounds') } - if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') + if (start < 0 || start >= this.length) throw new RangeError('Index out of range') if (end < 0) throw new RangeError('sourceEnd out of bounds') // Are we oob? diff --git a/test/node/test-buffer-alloc.js b/test/node/test-buffer-alloc.js index 597fa93..8b3e52b 100644 --- a/test/node/test-buffer-alloc.js +++ b/test/node/test-buffer-alloc.js @@ -977,14 +977,14 @@ assert.strictEqual(SlowBuffer.prototype.offset, undefined); }); assert.throws(() => Buffer.from(new ArrayBuffer(0), -1 >>> 0), errMsg); } -/* + // ParseArrayIndex() should reject values that don't fit in a 32 bits size_t. common.expectsError(() => { var a = Buffer.alloc(1); var b = Buffer.alloc(1); a.copy(b, 0, 0x100000000, 0x100000001); }, { code: undefined, type: RangeError, message: 'Index out of range' }); -*/ + // Unpooled buffer (replaces SlowBuffer) { var ubuf = Buffer.allocUnsafeSlow(10);