From 81a62f4f598f22c32f676af00da464e6fa18b4a6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 13 May 2023 18:50:27 +0200 Subject: [PATCH] LibJS/Bytecode: Fix bogus program termination after `try` with `catch` For `try` statements with a `catch` clause, we were generating *two* "next" blocks. This meant that not throwing an exception would cause execution to stop. Fix this by using the "next" block pointer for the try "entry" and "handler" blocks. --- Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp index 376705fb3e..734c345600 100644 --- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -2254,10 +2254,10 @@ Bytecode::CodeGenerationErrorOr TryStatement::generate_bytecode(Bytecode:: if (m_finalizer) { generator.emit(finalizer_target); } else { - auto& block = generator.make_block(); + if (!next_block) + next_block = &generator.make_block(); generator.emit(); - generator.emit(Bytecode::Label { block }); - next_block = █ + generator.emit(Bytecode::Label { *next_block }); } }