Fixed #860 (Improve double delete detection)

This commit is contained in:
Daniel Marjamäki 2009-10-27 21:28:03 +01:00
parent 9a1eb5c9e5
commit 45b0758e71
2 changed files with 4 additions and 1 deletions

View File

@ -1268,7 +1268,7 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all)
// Otherwise, only the "if" will be deleted
else if (Token::Match(tok2, "[;{}] if assign|dealloc|use ; !!else"))
{
if (_settings->_showAll)
if (_settings->_showAll && !Token::simpleMatch(tok2->tokAt(2), "dealloc ; dealloc"))
{
Token::eraseTokens(tok2, tok2->tokAt(3));
all = true;

View File

@ -512,6 +512,9 @@ private:
ASSERT_EQUALS("; alloc ;", simplifycode("; alloc ; if(!var) { exit; }"));
TODO_ASSERT_EQUALS(";", simplifycode("; alloc ; if(var) { exit; }"));
TODO_ASSERT_EQUALS(";\n; alloc ;", simplifycode("; alloc ; ifv { exit; }"));
// dealloc; dealloc;
ASSERT_EQUALS("; alloc ; dealloc ; dealloc ;", simplifycode("; alloc ; if { dealloc ; } dealloc ;"));
}