summaryrefslogtreecommitdiff
path: root/ext/web/08_text_encoding.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/web/08_text_encoding.js')
-rw-r--r--ext/web/08_text_encoding.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/ext/web/08_text_encoding.js b/ext/web/08_text_encoding.js
index d3f6d45fb..d2922a6d4 100644
--- a/ext/web/08_text_encoding.js
+++ b/ext/web/08_text_encoding.js
@@ -105,14 +105,19 @@
}
try {
- if (ArrayBufferIsView(input)) {
- input = new Uint8Array(
- input.buffer,
- input.byteOffset,
- input.byteLength,
- );
- } else {
- input = new Uint8Array(input);
+ try {
+ if (ArrayBufferIsView(input)) {
+ input = new Uint8Array(
+ input.buffer,
+ input.byteOffset,
+ input.byteLength,
+ );
+ } else {
+ input = new Uint8Array(input);
+ }
+ } catch {
+ // If the buffer is detached, just create a new empty Uint8Array.
+ input = new Uint8Array();
}
if (input.buffer instanceof SharedArrayBuffer) {
// We clone the data into a non-shared ArrayBuffer so we can pass it