mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +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
Notes:
sideshowbarker
2024-07-17 00:47:29 +09:00
Author: https://github.com/Lubrsi
Commit: b162c9117e
Pull-request: https://github.com/SerenityOS/serenity/pull/19641
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