From d3256c656e445aecb6ab10793da535e3e3395cfe Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Sun, 11 Oct 2026 06:59:48 -0700 Subject: [PATCH] Typecheck byte length input on constructor. --- src/lib/primordials.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/primordials.ts b/src/lib/primordials.ts index 90cc92a..7f2029e 100644 --- a/src/lib/primordials.ts +++ b/src/lib/primordials.ts @@ -83,6 +83,7 @@ function isArrayBuffer (a: unknown): a is ArrayBuffer { /** Captured version of `new Uint8Array(byteLength)`. */ export function allocate (length: number): Bytes { + if (typeof length !== 'number') throw 'Invalid byte length for Uint8Array constructor' return new Bytes(length) } -- 2.52.0