Fixed #860 (Improve double delete detection)
This commit is contained in:
parent
9a1eb5c9e5
commit
45b0758e71
|
@ -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;
|
||||
|
|
|
@ -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 ;"));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue