From 0419f86d14eb23ee5a48ec3494c34a559103e71d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 4 Dec 2025 09:03:35 -0800 Subject: [PATCH] fix --- src/wasm/wasm-binary.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 3ebd5d8ecba..7f385f16eb2 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -4733,12 +4733,15 @@ void WasmBinaryReader::readExports() { Expression* WasmBinaryReader::readExpression() { assert(builder.empty()); - while (input[pos] != BinaryConsts::End) { + while (more() && input[pos] != BinaryConsts::End) { auto inst = readInst(); if (auto* err = inst.getErr()) { throwError(err->msg); } } + if (!more()) { + throwError("unexpected end of input"); + } ++pos; auto expr = builder.build(); if (auto* err = expr.getErr()) {