From 864076fa0a195723b6c733d41f541298815b43bb Mon Sep 17 00:00:00 2001 From: "manjie.chen" Date: Mon, 13 May 2024 20:01:29 +0800 Subject: [PATCH] perfs: toASM throw error when receive invalid chunks --- src/script.js | 3 +++ ts_src/script.ts | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/script.js b/src/script.js index be2805190..0bc4475aa 100644 --- a/src/script.js +++ b/src/script.js @@ -158,6 +158,9 @@ function toASM(chunks) { if (chunksIsBuffer(chunks)) { chunks = decompile(chunks); } + if (!chunks) { + throw new Error('convert invalid chunks to ASM'); + } return chunks .map(chunk => { // data? diff --git a/ts_src/script.ts b/ts_src/script.ts index 54ee98fde..455dce3d3 100644 --- a/ts_src/script.ts +++ b/ts_src/script.ts @@ -168,7 +168,9 @@ export function toASM(chunks: Buffer | Array): string { if (chunksIsBuffer(chunks)) { chunks = decompile(chunks) as Stack; } - + if (!chunks) { + throw new Error('convert invalid chunks to ASM'); + } return chunks .map(chunk => { // data?