Skip to content

Commit

Permalink
buffer: improve ERR_BUFFER_OUT_OF_BOUNDS default
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
cjihrig authored and targos committed Aug 19, 2019
1 parent 66249bb commit c7a4525
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-readdouble.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-readfloat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-writedouble.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-writefloat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit c7a4525

Please sign in to comment.