Skip to content

Commit c7a4525

Browse files
cjihrigtargos
authored andcommitted
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 <[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]>
1 parent 66249bb commit c7a4525

7 files changed

+7
-7
lines changed

lib/internal/errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ E('ERR_BUFFER_OUT_OF_BOUNDS',
705705
if (name) {
706706
return `"${name}" is outside of buffer bounds`;
707707
}
708-
return 'Attempt to write outside buffer bounds';
708+
return 'Attempt to access memory outside buffer bounds';
709709
}, RangeError);
710710
E('ERR_BUFFER_TOO_LARGE',
711711
`Cannot create a Buffer larger than 0x${kMaxLength.toString(16)} bytes`,

test/parallel/test-buffer-fill.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ common.expectsError(() => {
362362
}, {
363363
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
364364
type: RangeError,
365-
message: 'Attempt to write outside buffer bounds'
365+
message: 'Attempt to access memory outside buffer bounds'
366366
});
367367

368368
assert.deepStrictEqual(

test/parallel/test-buffer-read.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const OOR_ERROR =
6060
const OOB_ERROR =
6161
{
6262
name: 'RangeError',
63-
message: 'Attempt to write outside buffer bounds'
63+
message: 'Attempt to access memory outside buffer bounds'
6464
};
6565

6666
// Attempt to overflow buffers, similar to previous bug in array buffers

test/parallel/test-buffer-readdouble.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ assert.strictEqual(buffer.readDoubleLE(0), -Infinity);
127127
{
128128
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
129129
name: 'RangeError',
130-
message: 'Attempt to write outside buffer bounds'
130+
message: 'Attempt to access memory outside buffer bounds'
131131
});
132132

133133
[NaN, 1.01].forEach((offset) => {

test/parallel/test-buffer-readfloat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ assert.strictEqual(buffer.readFloatLE(0), -Infinity);
9090
{
9191
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
9292
name: 'RangeError',
93-
message: 'Attempt to write outside buffer bounds'
93+
message: 'Attempt to access memory outside buffer bounds'
9494
});
9595

9696
[NaN, 1.01].forEach((offset) => {

test/parallel/test-buffer-writedouble.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ assert.ok(Number.isNaN(buffer.readDoubleLE(8)));
9999
{
100100
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
101101
name: 'RangeError',
102-
message: 'Attempt to write outside buffer bounds'
102+
message: 'Attempt to access memory outside buffer bounds'
103103
});
104104

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

test/parallel/test-buffer-writefloat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ assert.ok(Number.isNaN(buffer.readFloatLE(4)));
8181
{
8282
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
8383
name: 'RangeError',
84-
message: 'Attempt to write outside buffer bounds'
84+
message: 'Attempt to access memory outside buffer bounds'
8585
});
8686

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

0 commit comments

Comments
 (0)