Fixed #919 (possible memory leak not detected)

This commit is contained in:
Daniel Marjamäki 2009-11-13 20:22:28 +01:00
parent 2ec5438186
commit 1187587521
2 changed files with 2 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 && !Token::simpleMatch(tok2->tokAt(2), "dealloc ; dealloc"))
if (_settings->_showAll && tok2->tokAt(2)->str() != "assign" && !Token::simpleMatch(tok2->tokAt(2), "dealloc ; dealloc"))
{
Token::eraseTokens(tok2, tok2->tokAt(3));
all = true;

View File

@ -488,6 +488,7 @@ private:
ASSERT_EQUALS("; alloc ;", simplifycode("; alloc; if { dealloc; return; }"));
ASSERT_EQUALS("; alloc ;", simplifycode("; alloc; if { return use; }"));
ASSERT_EQUALS("; alloc ; return ;", simplifycode(";alloc;if{return;}return;"));
ASSERT_EQUALS("; alloc ; assign ; dealloc ;", simplifycode(";alloc;if{assign;}dealloc;"));
// switch..
ASSERT_EQUALS("; alloc ; dealloc ;", simplifycode(";alloc;switch{case;break;};dealloc;"));