From b8530c9c28ddf79808e9f49def049d1630f9f2cf Mon Sep 17 00:00:00 2001 From: TudbuT Date: Sat, 30 Apr 2022 19:17:11 +0200 Subject: [PATCH] fix stack size issue after catching an eror --- bootstrap/ISBPL.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bootstrap/ISBPL.java b/bootstrap/ISBPL.java index 708ef96..023386f 100644 --- a/bootstrap/ISBPL.java +++ b/bootstrap/ISBPL.java @@ -112,9 +112,17 @@ public class ISBPL { ISBPLCallable block = readBlock(i, words, file); i.getAndIncrement(); ISBPLCallable catcher = readBlock(i, words, file); + int stackHeight = stack.size(); try { block.call(stack); } catch (ISBPLError error) { + if(stack.size() > stackHeight) { + stack.setSize(stackHeight); + stack.trimToSize(); + } + while(stack.size() < stackHeight) { + stack.push(getNullObject()); + } if (Arrays.asList(allowed).contains(error.type) || allowed.length == 1 && allowed[0].equals("all")) { stack.push(toISBPLString(error.message)); stack.push(toISBPLString(error.type));