From: NAKAMURA Takumi Date: Sun, 25 Mar 2012 06:30:32 +0000 (+0000) Subject: clang/lib/Analysis/CFG.cpp: Fix memory leak since r153297. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9260f618e72f7c70dc76312f95d679f0ed03858c;p=clang 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 --- 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; } }