]> granicus.if.org Git - clang/commitdiff
clang/lib/Analysis/CFG.cpp: Fix memory leak since r153297.
authorNAKAMURA Takumi <geek4civic@gmail.com>
Sun, 25 Mar 2012 06:30:32 +0000 (06:30 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Sun, 25 Mar 2012 06:30:32 +0000 (06:30 +0000)
evaluateAsBooleanConditionNoCache(S) might update the map and invalidate the iterator.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153406 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFG.cpp

index 706d69010b47fe34c4eec319a78210650e2e9ec6..e54fae33fe86e5b8fa5676877605080f1352ffce 100644 (file)
@@ -457,8 +457,11 @@ private:
             CachedBoolEvals.insert(std::make_pair(S, TryResult()));
         if (!Inserted)
           return I->second; // already in map;
-    
-        return (I->second = evaluateAsBooleanConditionNoCache(S));
+
+        // Retrieve result at first, or the map might be updated.
+        TryResult Result = evaluateAsBooleanConditionNoCache(S);
+        CachedBoolEvals[S] = Result; // update or insert
+        return Result;
       }
     }