Skip to content

Commit ed6ec96

Browse files
authored
test: make buffer sizes 32bit-aware in test-internal-util-construct-sab
PR-URL: #61026 Fixes: #61025 Refs: #60497 Reviewed-By: Antoine du Hamel <[email protected]>
1 parent dff46c0 commit ed6ec96

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/parallel/test-internal-util-construct-sab.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33

44
require('../common');
55
const assert = require('assert');
6+
const { kMaxLength } = require('buffer');
67
const { isSharedArrayBuffer } = require('util/types');
78
const { constructSharedArrayBuffer } = require('internal/util');
89

910
// We're testing that we can construct a SAB even when the global is not exposed.
1011
assert.strictEqual(typeof SharedArrayBuffer, 'undefined');
1112

12-
for (const length of [undefined, 0, 1, 2 ** 32]) {
13+
for (const length of [undefined, 0, 1, 2 ** 16]) {
1314
assert(isSharedArrayBuffer(constructSharedArrayBuffer(length)));
1415
}
1516

16-
for (const length of [-1, Number.MAX_SAFE_INTEGER + 1, 2 ** 64]) {
17+
// Specifically test the following cases:
18+
// - out-of-range allocation requests should not crash the process
19+
// - no int64 overflow
20+
for (const length of [-1, kMaxLength + 1, 2 ** 64]) {
1721
assert.throws(() => constructSharedArrayBuffer(length), RangeError);
1822
}

0 commit comments

Comments
 (0)