Skip to content
Permalink
Browse files

buffer: improve ERR_BUFFER_OUT_OF_BOUNDS default

This commit changes the default message used by
ERR_BUFFER_OUT_OF_BOUNDS. Previously, the default
message implied that the problematic was always a
write, which is not accurate.

PR-URL: #29098
Fixes: #29097
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information...
cjihrig authored and targos committed Aug 12, 2019
1 parent 66249bb commit c7a4525bbe053c3a79504e558236c48d3c6acc5c
@@ -705,7 +705,7 @@ E('ERR_BUFFER_OUT_OF_BOUNDS',
if (name) {
return `"${name}" is outside of buffer bounds`;
}
return 'Attempt to write outside buffer bounds';
return 'Attempt to access memory outside buffer bounds';
}, RangeError);
E('ERR_BUFFER_TOO_LARGE',
`Cannot create a Buffer larger than 0x${kMaxLength.toString(16)} bytes`,
@@ -362,7 +362,7 @@ common.expectsError(() => {
}, {
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
type: RangeError,
message: 'Attempt to write outside buffer bounds'
message: 'Attempt to access memory outside buffer bounds'
});

assert.deepStrictEqual(
@@ -60,7 +60,7 @@ const OOR_ERROR =
const OOB_ERROR =
{
name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
message: 'Attempt to access memory outside buffer bounds'
};

// Attempt to overflow buffers, similar to previous bug in array buffers
@@ -127,7 +127,7 @@ assert.strictEqual(buffer.readDoubleLE(0), -Infinity);
{
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
message: 'Attempt to access memory outside buffer bounds'
});

[NaN, 1.01].forEach((offset) => {
@@ -90,7 +90,7 @@ assert.strictEqual(buffer.readFloatLE(0), -Infinity);
{
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
message: 'Attempt to access memory outside buffer bounds'
});

[NaN, 1.01].forEach((offset) => {
@@ -99,7 +99,7 @@ assert.ok(Number.isNaN(buffer.readDoubleLE(8)));
{
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
message: 'Attempt to access memory outside buffer bounds'
});

['', '0', null, {}, [], () => {}, true, false].forEach((off) => {
@@ -81,7 +81,7 @@ assert.ok(Number.isNaN(buffer.readFloatLE(4)));
{
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
name: 'RangeError',
message: 'Attempt to write outside buffer bounds'
message: 'Attempt to access memory outside buffer bounds'
});

['', '0', null, {}, [], () => {}, true, false].forEach((off) => {

0 comments on commit c7a4525

Please sign in to comment.
You can’t perform that action at this time.