From 0d6dbc08bec50aa1548703bf53dc632e0aeefbd6 Mon Sep 17 00:00:00 2001 From: Marcos Casagrande Date: Fri, 14 Oct 2022 11:38:17 +0200 Subject: fix(ext/fetch): throw TypeError on non-Uint8Array chunk (#16262) --- ext/web/06_streams.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ext/web') diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 933d7b09c..361e5e055 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -813,6 +813,12 @@ const { value: chunk, done } = await reader.read(); if (done) break; + if (!ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, chunk)) { + throw new TypeError( + "Can't convert value to Uint8Array while consuming the stream", + ); + } + ArrayPrototypePush(chunks, chunk); totalLength += chunk.byteLength; } -- cgit v1.2.3