Ghidra is a software reverse engineering (SRE) framework
GP-2021 varnode null issue refactor
ghidra007fb15d5eb06e5
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/Varnode.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/Varnode.javaindex 01987285d7..59d6d6c5e0 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/Varnode.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/Varnode.java@@ -292,15 +292,7 @@ public class Varnode {* @return the lone descendant PcodeOp*/public PcodeOp getLoneDescend() {- Iterator<PcodeOp> iter = getDescendants();- if (!iter.hasNext()) {- return null; // If there are no descendants return null- }- PcodeOp op = iter.next();- if (iter.hasNext()) {- return null; // If there is more than one descendant return null- }- return op;+ return null;}/**diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/VarnodeAST.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/VarnodeAST.javaindex a3c3241b6a..5b04b74d3c 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/VarnodeAST.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/VarnodeAST.java@@ -93,6 +93,19 @@ public class VarnodeAST extends Varnode {public Iterator<PcodeOp> getDescendants() {return descend.iterator();}++ @Override+ public PcodeOp getLoneDescend() {+ Iterator<PcodeOp> iter = getDescendants();+ if (!iter.hasNext()) {+ return null; // If there are no descendants return null+ }+ PcodeOp op = iter.next();+ if (iter.hasNext()) {+ return null; // If there is more than one descendant return null+ }+ return op;+ }@Overridepublic Address getPCAddress() {