From c595e60c65487ff579ae3e0f68addd800562ab0f Mon Sep 17 00:00:00 2001 From: caheckman Date: Tue, 2 Apr 2019 12:56:35 -0400 Subject: [PATCH] Fix for "Free Varnodes" exceptions in RuleConditionalMove --- Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc index af1165c37b..e4326eaffd 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc @@ -7333,8 +7333,12 @@ bool RuleConditionalMove::BoolExpress::evaluatePropagation(FlowBlock *root,FlowB if (root == branch) return true; // Can always propagate if there is no branch if (op->getParent() != branch) return true; // Can propagate if value formed before branch mustreconstruct = true; // Final op is performed in branch, so it must be reconstructed + if (in0->isFree() && !in0->isConstant()) return false; if (in0->isWritten() && (in0->getDef()->getParent()==branch)) return false; - if ((optype==2) && in1->isWritten() && (in1->getDef()->getParent()==branch)) return false; + if (optype == 2) { + if (in1->isFree() && !in1->isConstant()) return false; + if (in1->isWritten() && (in1->getDef()->getParent()==branch)) return false; + } return true; }