Skip to content

Commit b52f669

Browse files
authored
Fix null pointer dereference validating struct.new (#7688)
We would previously dereference a null descriptor operand to struct.new when the allocated type has a descriptor. This only happens in invalid IR, but the validator needs to handle that gracefully.
1 parent 6f4484c commit b52f669

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/wasm/wasm-validator.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3163,6 +3163,12 @@ void FunctionValidator::visitStructNew(StructNew* curr) {
31633163
curr,
31643164
"struct.new of type without descriptor should lack one");
31653165
} else {
3166+
if (!shouldBeTrue(
3167+
curr->desc,
3168+
curr,
3169+
"struct.new of type with descriptor requires descriptor operand")) {
3170+
return;
3171+
}
31663172
shouldBeSubType(curr->desc->type,
31673173
Type(*descType, Nullable, Exact),
31683174
curr,

0 commit comments

Comments
 (0)