aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CFRefCount.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-02-19 18:18:48 +0000
committerTed Kremenek <kremenek@apple.com>2009-02-19 18:18:48 +0000
commitb1dbf158db83b2b630621fa856a54c65d64e8632 (patch)
tree7c45c4b26a9fe0d5fdbbec08b2ee812310bc970c /lib/Analysis/CFRefCount.cpp
parent0be2ef2321b1283ead38ebeb83b451335d90e0fe (diff)
retain/release checker: Fix crasher when the leak site is the same expression that allocates an object.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65047 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFRefCount.cpp')
-rw-r--r--lib/Analysis/CFRefCount.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 939e20a02d..c86b960af1 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -2586,7 +2586,6 @@ CFRefLeakReport::getEndPath(BugReporter& br, const ExplodedNode<GRState>* EndN){
while (LeakN) {
ProgramPoint P = LeakN->getLocation();
-
if (const PostStmt *PS = dyn_cast<PostStmt>(&P))
S = PS->getStmt();
@@ -2597,18 +2596,27 @@ CFRefLeakReport::getEndPath(BugReporter& br, const ExplodedNode<GRState>* EndN){
// Scan 'S' for uses of Sym.
GRStateRef state(LeakN->getState(), BR.getStateManager());
bool foundSymbol = false;
-
- for (Stmt::child_iterator I=S->child_begin(), E=S->child_end();
- I!=E; ++I)
- if (Expr *Ex = dyn_cast_or_null<Expr>(*I)) {
- SVal X = state.GetSVal(Ex);
- if (isa<loc::SymbolVal>(X) &&
- cast<loc::SymbolVal>(X).getSymbol() == Sym){
- foundSymbol = true;
- break;
+
+ // First check if 'S' itself binds to the symbol.
+ if (Expr *Ex = dyn_cast<Expr>(S)) {
+ SVal X = state.GetSVal(Ex);
+ if (isa<loc::SymbolVal>(X) &&
+ cast<loc::SymbolVal>(X).getSymbol() == Sym)
+ foundSymbol = true;
+ }
+
+ if (!foundSymbol)
+ for (Stmt::child_iterator I=S->child_begin(), E=S->child_end();
+ I!=E; ++I)
+ if (Expr *Ex = dyn_cast_or_null<Expr>(*I)) {
+ SVal X = state.GetSVal(Ex);
+ if (isa<loc::SymbolVal>(X) &&
+ cast<loc::SymbolVal>(X).getSymbol() == Sym){
+ foundSymbol = true;
+ break;
+ }
}
- }
-
+
if (foundSymbol)
break;
}