diff options
author | Geert-Jan Zwiers <geertjanzwiers@protonmail.com> | 2022-05-26 17:15:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-26 17:15:44 +0200 |
commit | ab9c7f52e0a729de9d8c535cfd77e72cc1ca8512 (patch) | |
tree | cfab923ffc83aead1b59a39ed5db50584fb60391 /cli/tests | |
parent | 402b497299c04e3b4714842c5caad50197088d0c (diff) |
chore(serde_v8): throw error when string buffer exceeds v8 max length (#14588)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/buffer_test.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cli/tests/unit/buffer_test.ts b/cli/tests/unit/buffer_test.ts index 445c946e2..41d7e4d7f 100644 --- a/cli/tests/unit/buffer_test.ts +++ b/cli/tests/unit/buffer_test.ts @@ -446,3 +446,16 @@ Deno.test(function testBufferBytesCopyFalseGrowExactBytes() { assertEquals(actualBytes.byteLength, bufSize); assertEquals(actualBytes.buffer.byteLength, actualBytes.byteLength); }); + +Deno.test(function testThrowsErrorWhenBufferExceedsMaxLength() { + const kStringMaxLengthPlusOne = 536870888 + 1; + const bytes = new Uint8Array(kStringMaxLengthPlusOne); + + assertThrows( + () => { + new TextDecoder().decode(bytes); + }, + TypeError, + "buffer exceeds maximum length", + ); +}); |