From 4acb3099c386529a8da4fd42cb87484a486a60c3 Mon Sep 17 00:00:00 2001
From: Clark Coleman <clc@zephyr-software.com>
Date: Sun, 24 Feb 2019 18:53:27 -0500
Subject: [PATCH] Back off some memory leak fixes to prevent double-delete
 issues in STARS IRDB.

---
 src/base/SMPFunction.cpp | 2 ++
 src/base/SMPInstr.cpp    | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp
index 53a8e59b..5164428f 100644
--- a/src/base/SMPFunction.cpp
+++ b/src/base/SMPFunction.cpp
@@ -397,6 +397,7 @@ SMPFunction::~SMPFunction() {
 			delete this->ShadowCFGBlocks[i];
 	}
 
+#if 0 // crashes in STARS/IRDB ???
 	for (size_t i = 0; i < this->LoopInductionVars.size(); ++i) {
 		for (struct InductionVarFamily CurrFam : this->LoopInductionVars[i]) {
 			if (nullptr != CurrFam.BIVInitExpr)
@@ -405,6 +406,7 @@ SMPFunction::~SMPFunction() {
 				delete CurrFam.BIVLimitExpr;
 		}
 	}
+#endif
 
 	for (size_t i = 0; i < this->LoopMemAddrExprsFromCalleeLoops.size(); ++i) {
 		for (STARSExpression *CurrExpr : this->LoopMemAddrExprsFromCalleeLoops[i]) {
diff --git a/src/base/SMPInstr.cpp b/src/base/SMPInstr.cpp
index 61fb134a..ac33c3f8 100644
--- a/src/base/SMPInstr.cpp
+++ b/src/base/SMPInstr.cpp
@@ -4932,7 +4932,7 @@ SMPInstr::~SMPInstr() {
 		this->Uses.clear();
 	}
 #if 1  // fix crashes before enabling this
-	if (nullptr != this->STARSInstPtr) {
+	if (global_STARS_program->IsIDAProDriverMode() && (nullptr != this->STARSInstPtr)) {
 		delete this->STARSInstPtr;
 		this->STARSInstPtr = nullptr;
 	}
-- 
GitLab