From: Chris Duncan Date: Sun, 11 Oct 2026 13:59:48 +0000 (-0700) Subject: Typecheck byte length input on constructor. X-Git-Tag: v2.0.0~1^2~27 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=d3256c656e445aecb6ab10793da535e3e3395cfe;p=nano25519.git Typecheck byte length input on constructor. --- 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) }