From 54d55814afd222d03eb1ca5e24f35571c2e583f0 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Mon, 9 Dec 2024 22:16:24 +0200 Subject: [PATCH] fix: errors with out of range arguments --- .../java/me/topchetoeu/jscript/runtime/InstructionRunner.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/topchetoeu/jscript/runtime/InstructionRunner.java b/src/main/java/me/topchetoeu/jscript/runtime/InstructionRunner.java index cbb6857..dd44deb 100644 --- a/src/main/java/me/topchetoeu/jscript/runtime/InstructionRunner.java +++ b/src/main/java/me/topchetoeu/jscript/runtime/InstructionRunner.java @@ -469,7 +469,9 @@ public class InstructionRunner { } private static Value execLoadArg(Environment env, Instruction instr, Frame frame) { - frame.push(frame.args[(int)instr.get(0)]); + int i = instr.get(0); + if (i >= frame.args.length) frame.push(Value.UNDEFINED); + else frame.push(frame.args[i]); frame.codePtr++; return null; }