From ae1a0a633cdffeec5354f8233c1321b832a96488 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 25 Mar 2021 08:28:48 -0700 Subject: [Wasm GC] Properly validate struct.new number of operands (#3726) --- src/wasm/wasm-validator.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/wasm/wasm-validator.cpp') 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"); + } } } } -- cgit v1.2.3