Skip to content

Commit 4f52bff

Browse files
authored
Check for end of input while reading expressions (#8092)
If the input ends in an expression, we are missing at minimum the end of the function, so it is definitely invalid. Fixes #8089
1 parent 34f8d2f commit 4f52bff

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/wasm/wasm-binary.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4763,12 +4763,15 @@ void WasmBinaryReader::readExports() {
47634763

47644764
Expression* WasmBinaryReader::readExpression() {
47654765
assert(builder.empty());
4766-
while (input[pos] != BinaryConsts::End) {
4766+
while (more() && input[pos] != BinaryConsts::End) {
47674767
auto inst = readInst();
47684768
if (auto* err = inst.getErr()) {
47694769
throwError(err->msg);
47704770
}
47714771
}
4772+
if (!more()) {
4773+
throwError("unexpected end of input");
4774+
}
47724775
++pos;
47734776
auto expr = builder.build();
47744777
if (auto* err = expr.getErr()) {

0 commit comments

Comments
 (0)