|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: =?UTF-8?q?Ren=C3=A9?= <contact.9a5d6388@renegade334.me.uk> |
| 3 | +Date: Sat, 20 Dec 2025 22:20:21 +0000 |
| 4 | +Subject: test: make buffer sizes 32bit-aware in |
| 5 | + test-internal-util-construct-sab |
| 6 | + |
| 7 | +PR-URL: https://github.com/nodejs/node/pull/61026 |
| 8 | +Fixes: https://github.com/nodejs/node/issues/61025 |
| 9 | +Refs: https://github.com/nodejs/node/pull/60497 |
| 10 | +Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> |
| 11 | + |
| 12 | +diff --git a/test/parallel/test-internal-util-construct-sab.js b/test/parallel/test-internal-util-construct-sab.js |
| 13 | +index 5ff9b09f8e7d36a91825a38e861b8c2615c62500..403b59809e47d2e1d3503a059826f66334a2f035 100644 |
| 14 | +--- a/test/parallel/test-internal-util-construct-sab.js |
| 15 | ++++ b/test/parallel/test-internal-util-construct-sab.js |
| 16 | +@@ -3,16 +3,20 @@ |
| 17 | + |
| 18 | + require('../common'); |
| 19 | + const assert = require('assert'); |
| 20 | ++const { kMaxLength } = require('buffer'); |
| 21 | + const { isSharedArrayBuffer } = require('util/types'); |
| 22 | + const { constructSharedArrayBuffer } = require('internal/util'); |
| 23 | + |
| 24 | + // We're testing that we can construct a SAB even when the global is not exposed. |
| 25 | + assert.strictEqual(typeof SharedArrayBuffer, 'undefined'); |
| 26 | + |
| 27 | +-for (const length of [undefined, 0, 1, 2 ** 32]) { |
| 28 | ++for (const length of [undefined, 0, 1, 2 ** 16]) { |
| 29 | + assert(isSharedArrayBuffer(constructSharedArrayBuffer(length))); |
| 30 | + } |
| 31 | + |
| 32 | +-for (const length of [-1, Number.MAX_SAFE_INTEGER + 1, 2 ** 64]) { |
| 33 | ++// Specifically test the following cases: |
| 34 | ++// - out-of-range allocation requests should not crash the process |
| 35 | ++// - no int64 overflow |
| 36 | ++for (const length of [-1, kMaxLength + 1, 2 ** 64]) { |
| 37 | + assert.throws(() => constructSharedArrayBuffer(length), RangeError); |
| 38 | + } |
0 commit comments