From 470e77a5725fdb0eeffa9475a14937779dce364c Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Thu, 21 Oct 2021 22:48:33 +0300 Subject: [PATCH] + added sanity check when resolving labels to ensure we don't get any jumps with negative nesting depth --- compiler/wasm32/cpupi.pas | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/wasm32/cpupi.pas b/compiler/wasm32/cpupi.pas index 666dc0ec6e..8deb18eeb4 100644 --- a/compiler/wasm32/cpupi.pas +++ b/compiler/wasm32/cpupi.pas @@ -516,7 +516,8 @@ implementation (instr.oper[0]^.ref^.index<>NR_NO) or (instr.oper[0]^.ref^.offset<>0) then internalerror(2021102006); - if instr.oper[0]^.ref^.symbol.nestingdepth<>-1 then + if (instr.oper[0]^.ref^.symbol.nestingdepth<>-1) and + (cur_nesting_depth>=instr.oper[0]^.ref^.symbol.nestingdepth) then instr.loadconst(0,cur_nesting_depth-instr.oper[0]^.ref^.symbol.nestingdepth) else begin