summaryrefslogtreecommitdiffstats
path: root/lib/Analysis
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2012-03-25 06:30:32 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2012-03-25 06:30:32 +0000
commit9260f618e72f7c70dc76312f95d679f0ed03858c (patch)
tree0234c5b2bcb100c47c3daf6fad11abe3a514a541 /lib/Analysis
parentb293f524f68330bfc78ae4df14da75938e98e000 (diff)
clang/lib/Analysis/CFG.cpp: Fix memory leak since r153297.
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
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/CFG.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index 706d69010b..e54fae33fe 100644
--- a/lib/Analysis/CFG.cpp
+++ b/lib/Analysis/CFG.cpp
@@ -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;
}
}