mirror of
https://github.com/RGBCube/serenity
synced 2025-06-28 21:02:07 +00:00
LibJS/Bytecode: Set accumulator to undefined at start of catch blocks
Otherwise we leak the error value through to the result.
This commit is contained in:
parent
1789905d4a
commit
b162c9117e
1 changed files with 5 additions and 0 deletions
|
@ -2086,6 +2086,11 @@ Bytecode::CodeGenerationErrorOr<void> TryStatement::generate_bytecode(Bytecode::
|
|||
return {};
|
||||
}));
|
||||
|
||||
// Set accumulator to undefined, otherwise we leak the error object through the accumulator.
|
||||
// For example: `try { BigInt.call() } catch {}` would result in the error object. Note that
|
||||
// the exception _is_ caught here, it just leaks the error object through to the result.
|
||||
generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
|
||||
|
||||
TRY(m_handler->body().generate_bytecode(generator));
|
||||
handler_target = Bytecode::Label { handler_block };
|
||||
generator.end_variable_scope();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue