Skip to content

Commit 583538b

Browse files
committed
test: make buffer sizes 32bit-aware in test-internal-util-construct-sab
nodejs/node#61026
1 parent 3984d4d commit 583538b

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

patches/node/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ fix_ensure_traverseparent_bails_on_resource_path_exit.patch
4343
reland_temporal_unflag_temporal.patch
4444
src_handle_der_decoding_errors_from_system_certificates.patch
4545
fix_suppress_nodiscard_warning_for_copy_options_operator.patch
46+
test_make_buffer_sizes_32bit-aware_in.patch
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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

Comments
 (0)