Fixed #1407 (false positive memory leak when returning pointer to the allocated memory)
This commit is contained in:
parent
d0348fa57a
commit
a6c9a6fc54
|
@ -1586,9 +1586,9 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all)
|
|||
}
|
||||
|
||||
// Reduce "alloc|dealloc|use|callfunc ; exit ;" => "; exit ;"
|
||||
if (Token::Match(tok2, "alloc|dealloc|use|callfunc ; exit ;"))
|
||||
if (Token::Match(tok2, "[;{}] alloc|dealloc|use|callfunc ; exit ;"))
|
||||
{
|
||||
tok2->deleteThis();
|
||||
tok2->deleteNext();
|
||||
done = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -665,6 +665,9 @@ private:
|
|||
ASSERT_EQUALS("; alloc ; return ;", simplifycode(";alloc;if{return;}return;"));
|
||||
ASSERT_EQUALS("; alloc ; assign ; dealloc ;", simplifycode(";alloc;if{assign;}dealloc;"));
|
||||
|
||||
// if(var)
|
||||
ASSERT_EQUALS("; alloc ; return use ;", simplifycode("; alloc ; return use ;"));
|
||||
|
||||
// switch..
|
||||
ASSERT_EQUALS("; alloc ; dealloc ;", simplifycode(";alloc;switch{case;break;};dealloc;"));
|
||||
ASSERT_EQUALS("; if return ;", simplifycode("; switch { case ; return ; default ; break ; }"));
|
||||
|
|
Loading…
Reference in New Issue