diff options
| author | 2025-10-18 12:19:17 +0200 | |
|---|---|---|
| committer | 2025-10-18 11:19:17 +0100 | |
| commit | 12012208cd8a07c5eebb66664f10320498e7d56e (patch) | |
| tree | e7ada801c08c770060bc54d783b8ef8db6dd9d16 | |
| parent | Fix opening jars via the menu bar not being possible (#571) (diff) | |
| download | enigma-fork-12012208cd8a07c5eebb66664f10320498e7d56e.tar.gz enigma-fork-12012208cd8a07c5eebb66664f10320498e7d56e.tar.xz enigma-fork-12012208cd8a07c5eebb66664f10320498e7d56e.zip | |
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>
| -rw-r--r-- | enigma/src/main/java/cuchaz/enigma/analysis/index/IndexReferenceVisitor.java | 6 |
1 files changed, 5 insertions, 1 deletions
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 { | |||
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | private ReferenceTargetType getReferenceTargetType(int stackDepth) { | 141 | private ReferenceTargetType getReferenceTargetType(int stackDepth) { |
| 142 | if (stack == null) { // Unreachable instruction | ||
| 143 | return ReferenceTargetType.uninitialized(); | ||
| 144 | } | ||
| 145 | |||
| 142 | if (stackDepth >= stack.size()) { | 146 | if (stackDepth >= stack.size()) { |
| 143 | throw new IllegalStateException("Stack depth " + stackDepth + " is higher than the stack: " + stackValuesToString(stack) + " in method " + callerEntry); | 147 | throw new IllegalStateException("Stack depth " + stackDepth + " is higher than the stack: " + stackValuesToString(stack) + " in method " + callerEntry); |
| 144 | } | 148 | } |
| 145 | 149 | ||
| 146 | Object stackValue = stack.get(stack.size() - 1 - stackDepth); | 150 | Object stackValue = stack.get(stack.size() - 1 - stackDepth); |
| 147 | 151 | ||
| 148 | if (stackValue.equals(Opcodes.UNINITIALIZED_THIS) || stackValue instanceof Label) { | 152 | if (stackValue.equals(Opcodes.UNINITIALIZED_THIS) || stackValue.equals(Opcodes.NULL) || stackValue instanceof Label) { |
| 149 | return ReferenceTargetType.uninitialized(); | 153 | return ReferenceTargetType.uninitialized(); |
| 150 | } | 154 | } |
| 151 | 155 | ||