1
Fork 0
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:
Luke Wilde 2023-06-25 20:52:06 +01:00 committed by Andreas Kling
parent 1789905d4a
commit b162c9117e

View file

@ -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();