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
This commit is contained in:
Ted Kremenek 2009-02-19 18:18:48 +00:00
Родитель 0be2ef2321
Коммит b1dbf158db
1 изменённых файлов: 20 добавлений и 12 удалений

Просмотреть файл

@ -2587,7 +2587,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();
else if (const BlockEdge *BE = dyn_cast<BlockEdge>(&P))
@ -2598,16 +2597,25 @@ CFRefLeakReport::getEndPath(BugReporter& br, const ExplodedNode<GRState>* EndN){
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;