]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix BugType memory leak in IdempotentOperationChecker.
authorTom Care <tom.care@uqconnect.edu.au>
Thu, 31 May 2012 21:24:58 +0000 (21:24 +0000)
committerTom Care <tom.care@uqconnect.edu.au>
Thu, 31 May 2012 21:24:58 +0000 (21:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157772 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp

index c08f163a1f7b8432282720745a198936181c2d56..9d0b83f40b340cd639067c95ab636a2563c04280 100644 (file)
@@ -106,6 +106,7 @@ private:
   typedef llvm::DenseMap<const BinaryOperator *, BinaryOperatorData>
       AssumptionMap;
   mutable AssumptionMap hash;
+  mutable OwningPtr<BugType> BT;
 };
 }
 
@@ -343,7 +344,9 @@ void IdempotentOperationChecker::checkPostStmt(const BinaryOperator *B,
 void IdempotentOperationChecker::checkEndAnalysis(ExplodedGraph &G,
                                                   BugReporter &BR,
                                                   ExprEngine &Eng) const {
-  BugType *BT = new BugType("Idempotent operation", "Dead code");
+  if (!BT)
+    BT.reset(new BugType("Idempotent operation", "Dead code"));
+
   // Iterate over the hash to see if we have any paths with definite
   // idempotent operations.
   for (AssumptionMap::const_iterator i = hash.begin(); i != hash.end(); ++i) {