LibWasm: Make sure try_table creates a new frame while validating

The spec says that while validating this opcode a new label should
be pushed.

Fixes a crash in instance.wast on WPT.
This commit is contained in:
Undefine 2025-10-19 16:41:24 +02:00 committed by Ali Mohammad Pur
parent 07c86542b6
commit 7bccd65b4a
Notes: github-actions[bot] 2025-10-19 15:29:18 +00:00
2 changed files with 11 additions and 0 deletions

View file

@ -2091,6 +2091,16 @@ VALIDATE_INSTRUCTION(try_table)
{
auto& args = instruction.arguments().get<Instruction::TryTableArgs>();
auto block_type = TRY(validate(args.try_.block_type));
auto& parameters = block_type.parameters();
for (size_t i = 1; i <= parameters.size(); ++i)
TRY(stack.take(parameters[parameters.size() - i]));
m_frames.empend(block_type, FrameKind::TryTable, stack.size());
m_max_frame_size = max(m_max_frame_size, m_frames.size());
for (auto& parameter : parameters)
stack.append(parameter);
for (auto& catch_ : args.catches) {
auto label = catch_.target_label();
TRY(validate(label));

View file

@ -151,6 +151,7 @@ public:
If,
Else,
Function,
TryTable,
};
struct Frame {