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: https://github.com/nodejs/node/pull/29098 Fixes: https://github.com/nodejs/node/issues/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>
This commit is contained in:
parent
427e5348a2
commit
a352a7129e
@ -710,7 +710,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) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user