]> git.codecow.com Git - nano25519.git/commitdiff
Typecheck byte length input on constructor.
authorChris Duncan <chris@codecow.com>
Sun, 11 Oct 2026 13:59:48 +0000 (06:59 -0700)
committerChris Duncan <chris@codecow.com>
Sun, 11 Oct 2026 13:59:48 +0000 (06:59 -0700)
src/lib/primordials.ts

index 90cc92ab6891392ac1078b60e38ca92e909fbc51..7f2029e3755c3524dfbccfea5d8ff75dbd39f082 100644 (file)
@@ -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)
 }