LibWasm: Improve element validation and instantiation

This commit is contained in:
Diego 2024-06-16 06:42:00 -07:00 committed by Ali Mohammad Pur
commit 3225e6fad2
Notes: sideshowbarker 2024-07-17 07:19:27 +09:00
3 changed files with 13 additions and 7 deletions

View file

@ -1281,10 +1281,10 @@ ParseResult<ElementSection::Element> ElementSection::Element::parse(Stream& stre
Vector<Expression> items;
if (!has_exprs) {
auto indices = TRY(parse_vector<GenericIndexParser<FunctionIndex>>(stream));
Vector<Instruction> instructions;
for (auto& index : indices)
instructions.empend(Instructions::ref_func, index);
items = { Expression { move(instructions) } };
for (auto& index : indices) {
Vector<Instruction> instructions { Instruction(Instructions::ref_func, index) };
items.empend(move(instructions));
}
} else {
items = TRY(parse_vector<Expression>(stream));
}