Skip to content

Commit 1201220

Browse files
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 <burtonjae@hotmail.co.uk> --------- Co-authored-by: Joseph Burton <burtonjae@hotmail.co.uk>
1 parent 90942d2 commit 1201220

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

enigma/src/main/java/cuchaz/enigma/analysis/index/IndexReferenceVisitor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,17 @@ public void visitInvokeDynamicInsn(String name, String descriptor, Handle bootst
139139
}
140140

141141
private ReferenceTargetType getReferenceTargetType(int stackDepth) {
142+
if (stack == null) { // Unreachable instruction
143+
return ReferenceTargetType.uninitialized();
144+
}
145+
142146
if (stackDepth >= stack.size()) {
143147
throw new IllegalStateException("Stack depth " + stackDepth + " is higher than the stack: " + stackValuesToString(stack) + " in method " + callerEntry);
144148
}
145149

146150
Object stackValue = stack.get(stack.size() - 1 - stackDepth);
147151

148-
if (stackValue.equals(Opcodes.UNINITIALIZED_THIS) || stackValue instanceof Label) {
152+
if (stackValue.equals(Opcodes.UNINITIALIZED_THIS) || stackValue.equals(Opcodes.NULL) || stackValue instanceof Label) {
149153
return ReferenceTargetType.uninitialized();
150154
}
151155

0 commit comments

Comments
 (0)