retain/release checker: Fix crasher when the leak site is the same expression that allocates an object.
llvm-svn: 65047
This commit is contained in:
parent
780b46fd50
commit
deafc5c601
|
@ -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,6 +2597,15 @@ CFRefLeakReport::getEndPath(BugReporter& br, const ExplodedNode<GRState>* EndN){
|
|||
GRStateRef state(LeakN->getState(), BR.getStateManager());
|
||||
bool foundSymbol = false;
|
||||
|
||||
// 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)) {
|
||||
|
|
Loading…
Reference in New Issue