Memory leaks : Remove "if break|continue ;" that may otherwise cause false positives

This commit is contained in:
Daniel Marjamäki 2008-12-18 07:20:31 +00:00
parent 69137597f5
commit 8d6f77deed
1 changed files with 9 additions and 1 deletions

View File

@ -762,6 +762,14 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok)
done = false;
}
}
// Remove the "if break|continue ;" that follows "dealloc ; alloc ;"
if ( ! _settings._showAll && TOKEN::Match(tok2, "dealloc ; alloc ; if break|continue ;") )
{
tok2 = tok2->next()->next()->next();
erase(tok2, tok2->tokAt(3));
done = false;
}
// Reduce "if ; else %var% ;" => "if %var% ;"
if ( TOKEN::Match(tok2, "if ; else %var% ;") )
@ -1048,7 +1056,7 @@ void CheckMemoryLeakClass::CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const
}
else if ( (result = TOKEN::findmatch(tok, "alloc ; if break|continue|return ;")) != NULL )
{
{
MemoryLeak(result->tokAt(3), varname, alloctype);
}