Skip to content

Commit

Permalink
fixup! lib: fix TypeError when converting a detached buffer source
Browse files Browse the repository at this point in the history
  • Loading branch information
cola119 committed Oct 31, 2022
1 parent a8ed04f commit 2007eb5
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/internal/encoding.js
Expand Up @@ -491,10 +491,18 @@ function makeTextDecoderJS() {
decode(input = empty, options = kEmptyObject) {
validateDecoder(this);
if (isAnyArrayBuffer(input)) {
input = lazyBuffer().from(input);
try {
input = lazyBuffer().from(input);
} catch {
input = empty;
}
} else if (isArrayBufferView(input)) {
input = lazyBuffer().from(input.buffer, input.byteOffset,
input.byteLength);
try {
input = lazyBuffer().from(input.buffer, input.byteOffset,
input.byteLength);
} catch {
input = empty;
}
} else {
throw new ERR_INVALID_ARG_TYPE('input',
['ArrayBuffer', 'ArrayBufferView'],
Expand Down

0 comments on commit 2007eb5

Please sign in to comment.