From 0064c74ac8b5a0f90c524a5160d4bc1a24b563a7 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Sat, 21 Sep 2024 18:46:02 +0300 Subject: [PATCH] fix: don't allow execution of CALL_SUPER twice or in non-construct call --- .../java/me/topchetoeu/jscript/runtime/InstructionRunner.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/me/topchetoeu/jscript/runtime/InstructionRunner.java b/src/main/java/me/topchetoeu/jscript/runtime/InstructionRunner.java index 10d1b15..db4ec83 100644 --- a/src/main/java/me/topchetoeu/jscript/runtime/InstructionRunner.java +++ b/src/main/java/me/topchetoeu/jscript/runtime/InstructionRunner.java @@ -40,6 +40,9 @@ public class InstructionRunner { return null; } private static Value execCallSuper(Environment env, Instruction instr, Frame frame) { + if (!frame.isNew) throw EngineException.ofError("Super constructor may be called only when constructing"); + if (frame.self != null) throw EngineException.ofError("Super constructor may be called once"); + var callArgs = frame.take(instr.get(0)); var superFunc = frame.pop();