Skip to content

Commit 1251efb

Browse files
authored
Avoid assertion in BrOn parsing (#8635)
The ref and the desc are used as references in `finalize()`, and we assert there if they are e.g. `i32`. Fixes #8633
1 parent 534eab9 commit 1251efb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/wasm/wasm-ir-builder.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,6 +2093,15 @@ Result<> IRBuilder::makeBrOn(Index label,
20932093
}
20942094
CHECK_ERR(visitBrOn(&curr));
20952095

2096+
// Validate things that would cause errors later.
2097+
if (curr.ref->type != Type::unreachable && !curr.ref->type.isRef()) {
2098+
return Err{"br_on* ref must be a ref"};
2099+
}
2100+
if (curr.desc && curr.desc->type != Type::unreachable &&
2101+
!curr.desc->type.isRef()) {
2102+
return Err{"br_on_cast_desc* must be a ref"};
2103+
}
2104+
20962105
// Validate type immediates before we forget them.
20972106
switch (op) {
20982107
case BrOnNull:

0 commit comments

Comments
 (0)