From 0b36af95fcab412a5a1fef942aa660cdb4e6d881 Mon Sep 17 00:00:00 2001 From: Renegade334 Date: Thu, 11 Dec 2025 19:13:56 +0000 Subject: [PATCH] test: make buffer sizes 32bit-aware in test-internal-util-construct-sab --- test/parallel/test-internal-util-construct-sab.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-internal-util-construct-sab.js b/test/parallel/test-internal-util-construct-sab.js index 5ff9b09f8e7d36..403b59809e47d2 100644 --- a/test/parallel/test-internal-util-construct-sab.js +++ b/test/parallel/test-internal-util-construct-sab.js @@ -3,16 +3,20 @@ require('../common'); const assert = require('assert'); +const { kMaxLength } = require('buffer'); const { isSharedArrayBuffer } = require('util/types'); const { constructSharedArrayBuffer } = require('internal/util'); // We're testing that we can construct a SAB even when the global is not exposed. assert.strictEqual(typeof SharedArrayBuffer, 'undefined'); -for (const length of [undefined, 0, 1, 2 ** 32]) { +for (const length of [undefined, 0, 1, 2 ** 16]) { assert(isSharedArrayBuffer(constructSharedArrayBuffer(length))); } -for (const length of [-1, Number.MAX_SAFE_INTEGER + 1, 2 ** 64]) { +// Specifically test the following cases: +// - out-of-range allocation requests should not crash the process +// - no int64 overflow +for (const length of [-1, kMaxLength + 1, 2 ** 64]) { assert.throws(() => constructSharedArrayBuffer(length), RangeError); }