summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-03-25 08:28:48 -0700
committerGitHub <noreply@github.com>2021-03-25 08:28:48 -0700
commitae1a0a633cdffeec5354f8233c1321b832a96488 (patch)
treeb68ef86e910d576a7155f458b67b3e31f1657555 /src/wasm/wasm-validator.cpp
parent4506ffba7da377044e5a4a6d9385591ff730221c (diff)
downloadbinaryen-ae1a0a633cdffeec5354f8233c1321b832a96488.tar.gz
binaryen-ae1a0a633cdffeec5354f8233c1321b832a96488.tar.bz2
binaryen-ae1a0a633cdffeec5354f8233c1321b832a96488.zip
[Wasm GC] Properly validate struct.new number of operands (#3726)
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 14955ecae..425792e22 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -2302,16 +2302,17 @@ void FunctionValidator::visitStructNew(StructNew* curr) {
"struct.new_with_default value type must be defaultable");
}
} else {
- shouldBeEqual(curr->operands.size(),
- fields.size(),
- curr,
- "struct.new must have the right number of operands");
- // All the fields must have the proper type.
- for (Index i = 0; i < fields.size(); i++) {
- shouldBeSubType(curr->operands[i]->type,
- fields[i].type,
+ if (shouldBeEqual(curr->operands.size(),
+ fields.size(),
curr,
- "struct.new operand must have proper type");
+ "struct.new must have the right number of operands")) {
+ // All the fields must have the proper type.
+ for (Index i = 0; i < fields.size(); i++) {
+ shouldBeSubType(curr->operands[i]->type,
+ fields[i].type,
+ curr,
+ "struct.new operand must have proper type");
+ }
}
}
}