Skip to content

Ghidra is a software reverse engineering (SRE) framework

Fix for HighSymbolTest

caheckmanef7728181dc9
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/AbstractDecompilerAction.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/AbstractDecompilerAction.java
index 2edf4ce150..8358fd236c 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/AbstractDecompilerAction.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/AbstractDecompilerAction.java
@@ -100,6 +100,9 @@ public abstract class AbstractDecompilerAction extends DockingAction {
HighVariable variable = token.getHighVariable();
HighSymbol highSymbol = null;
if (variable == null) {
+ if (highFunction == null) {
+ return null;
+ }
// Token may be from a variable reference, in which case we have to dig to find the actual symbol
Function function = highFunction.getFunction();
if (function == null) {
diff --git a/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/HighSymbolTest.java b/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/HighSymbolTest.java
index 974b03c499..06244e3876 100644
--- a/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/HighSymbolTest.java
+++ b/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/HighSymbolTest.java
@@ -199,7 +199,7 @@ public class HighSymbolTest extends AbstractDecompilerTest {
public void testHighSymbol_localStackDynamic() {
decompile("10015a6");
ClangTextField line = getLineContaining(" = 0xc;");
- FieldLocation loc = loc(line.getLineNumber(), 5);
+ FieldLocation loc = loc(line.getLineNumber(), 2);
ClangToken token = line.getToken(loc);
assertTrue(token instanceof ClangVariableToken);
HighVariable variable = token.getHighVariable();
@@ -321,7 +321,7 @@ public class HighSymbolTest extends AbstractDecompilerTest {
public void testHighSymbol_multipleUsePoints() {
decompile("1001915");
ClangTextField line = getLineContaining("0x4e");
- FieldLocation loc = loc(line.getLineNumber(), 4);
+ FieldLocation loc = loc(line.getLineNumber(), 2);
ClangToken token = line.getToken(loc);
assertTrue(token instanceof ClangVariableToken);
HighVariable variable = token.getHighVariable();