From f0434b09fccec48e3c01fc91fc7a58004a3d96e5 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Sun, 25 Mar 2012 06:30:32 +0000 Subject: clang/lib/Analysis/CFG.cpp: Fix memory leak since r153297. evaluateAsBooleanConditionNoCache(S) might update the map and invalidate the iterator. llvm-svn: 153406 --- clang/lib/Analysis/CFG.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'clang/lib/Analysis/CFG.cpp') diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 706d69010b4..e54fae33fe8 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/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; } } -- cgit v1.2.3