Skip to content

Commit 2007eb5

Browse files
committed
fixup! lib: fix TypeError when converting a detached buffer source
1 parent a8ed04f commit 2007eb5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/internal/encoding.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,18 @@ function makeTextDecoderJS() {
491491
decode(input = empty, options = kEmptyObject) {
492492
validateDecoder(this);
493493
if (isAnyArrayBuffer(input)) {
494-
input = lazyBuffer().from(input);
494+
try {
495+
input = lazyBuffer().from(input);
496+
} catch {
497+
input = empty;
498+
}
495499
} else if (isArrayBufferView(input)) {
496-
input = lazyBuffer().from(input.buffer, input.byteOffset,
497-
input.byteLength);
500+
try {
501+
input = lazyBuffer().from(input.buffer, input.byteOffset,
502+
input.byteLength);
503+
} catch {
504+
input = empty;
505+
}
498506
} else {
499507
throw new ERR_INVALID_ARG_TYPE('input',
500508
['ArrayBuffer', 'ArrayBufferView'],

0 commit comments

Comments
 (0)