summaryrefslogtreecommitdiffhomepage
path: root/compiler.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-03-23 11:05:25 +0100
committerJo-Philipp Wich <jo@mein.io>2021-03-23 12:30:20 +0100
commit091ae1b198e019430f342ae1444c68d6517e077e (patch)
treee4dcaebc23cadcb82ddca59f308fdc1bb71f3f5a /compiler.c
parentfcedb19bdcf09c120818ea39fec6caa7c504dad6 (diff)
compiler: fix another try/catch miscompilation
When skipping over the catch block of a try/catch statement, make sure to emit the jump after the try scope variables have been popped off the stack in order to prevent a stack position mismatch between compiler and vm. Fixes: 9ad9afb ("compiler: fix try/catch miscompilation") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'compiler.c')
-rw-r--r--compiler.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler.c b/compiler.c
index 15c8f8e..1b0d1c4 100644
--- a/compiler.c
+++ b/compiler.c
@@ -2427,14 +2427,14 @@ uc_compiler_compile_try(uc_compiler *compiler)
!uc_compiler_parse_check(compiler, TK_EOF))
uc_compiler_compile_declaration(compiler);
- /* jump beyond catch branch */
- try_to = chunk->count;
- jmp_off = uc_compiler_emit_jmp(compiler, 0, 0);
-
uc_compiler_parse_consume(compiler, TK_RBRACE);
uc_compiler_leave_scope(compiler);
+ /* jump beyond catch branch */
+ try_to = chunk->count;
+ jmp_off = uc_compiler_emit_jmp(compiler, 0, 0);
+
/* Catch block ---------------------------------------------------------- */
if (try_to > try_from) {