summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-06-25 09:05:45 -0700
committerGitHub <noreply@github.com>2024-06-25 09:05:45 -0700
commita9f6bc020ad8f483d14ad03cfb957da5dd1d290b (patch)
treec3d42576eb423676d1a693717069fac0e0bad57b
parent4e07d867f8c4cbcf0180ad439a08c46353bc3751 (diff)
downloadbinaryen-a9f6bc020ad8f483d14ad03cfb957da5dd1d290b.tar.gz
binaryen-a9f6bc020ad8f483d14ad03cfb957da5dd1d290b.tar.bz2
binaryen-a9f6bc020ad8f483d14ad03cfb957da5dd1d290b.zip
Add a missing binary reading check for BrOn's reference child's type (#6700)
That child must be a reference, as `finalize()` assumes so. To avoid an assertion, error early. Fixes #6696
-rw-r--r--src/wasm/wasm-binary.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index b76a789de..b23478205 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -7320,6 +7320,9 @@ bool WasmBinaryReader::maybeVisitBrOn(Expression*& out, uint32_t code) {
}
auto name = getBreakTarget(getU32LEB()).name;
auto* ref = popNonVoidExpression();
+ if (!ref->type.isRef() && ref->type != Type::unreachable) {
+ throwError("bad input type for br_on*");
+ }
if (isCast) {
auto inputNullability = (flags & 1) ? Nullable : NonNullable;
auto castNullability = (flags & 2) ? Nullable : NonNullable;