From 12012208cd8a07c5eebb66664f10320498e7d56e Mon Sep 17 00:00:00 2001 From: Geolykt Date: Sat, 18 Oct 2025 12:19:17 +0200 Subject: Properly handle unreachable instructions and null stack entries (#574) * Properly handle unreachable instructions and null stack entries * ASM can be trusted Co-authored-by: Joseph Burton --------- Co-authored-by: Joseph Burton --- .../java/cuchaz/enigma/analysis/index/IndexReferenceVisitor.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/enigma/src/main/java/cuchaz/enigma/analysis/index/IndexReferenceVisitor.java b/enigma/src/main/java/cuchaz/enigma/analysis/index/IndexReferenceVisitor.java index ecd460d..698a351 100644 --- a/enigma/src/main/java/cuchaz/enigma/analysis/index/IndexReferenceVisitor.java +++ b/enigma/src/main/java/cuchaz/enigma/analysis/index/IndexReferenceVisitor.java @@ -139,13 +139,17 @@ public class IndexReferenceVisitor extends ClassVisitor { } private ReferenceTargetType getReferenceTargetType(int stackDepth) { + if (stack == null) { // Unreachable instruction + return ReferenceTargetType.uninitialized(); + } + if (stackDepth >= stack.size()) { throw new IllegalStateException("Stack depth " + stackDepth + " is higher than the stack: " + stackValuesToString(stack) + " in method " + callerEntry); } Object stackValue = stack.get(stack.size() - 1 - stackDepth); - if (stackValue.equals(Opcodes.UNINITIALIZED_THIS) || stackValue instanceof Label) { + if (stackValue.equals(Opcodes.UNINITIALIZED_THIS) || stackValue.equals(Opcodes.NULL) || stackValue instanceof Label) { return ReferenceTargetType.uninitialized(); } -- cgit v1.2.3