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; }