Fixed #715 (False positive: Resource leak when exit() after if loop)
This commit is contained in:
parent
faac5bccd6
commit
ad92aa4c20
|
@ -1352,13 +1352,21 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all)
|
|||
done = false;
|
||||
}
|
||||
|
||||
// Reduce "alloc|dealloc|use ; exit ;" => "; exit ;"
|
||||
// Reduce "alloc|dealloc|use|callfunc ; exit ;" => "; exit ;"
|
||||
if (Token::Match(tok2, "alloc|dealloc|use|callfunc ; exit ;"))
|
||||
{
|
||||
tok2->deleteThis();
|
||||
done = false;
|
||||
}
|
||||
|
||||
// Reduce "if loop ; exit ;" => "; exit ;"
|
||||
if (Token::Match(tok2, "if loop ; exit ;"))
|
||||
{
|
||||
tok2->deleteThis();
|
||||
tok2->deleteThis();
|
||||
done = false;
|
||||
}
|
||||
|
||||
// Reduce "alloc|dealloc|use ; if(var) exit ;"
|
||||
if (Token::Match(tok2, "alloc|dealloc|use ; if(var) exit ;"))
|
||||
{
|
||||
|
|
|
@ -490,6 +490,7 @@ private:
|
|||
|
||||
// exit..
|
||||
ASSERT_EQUALS("; exit ;", simplifycode("; alloc; exit;"));
|
||||
ASSERT_EQUALS("; exit ;", simplifycode("; alloc; if { loop ; } dealloc; exit;"));
|
||||
ASSERT_EQUALS(";", simplifycode("; if { alloc; exit; }"));
|
||||
ASSERT_EQUALS("; alloc ;", simplifycode("; alloc ; if { use; exit; }"));
|
||||
ASSERT_EQUALS("; alloc ;", simplifycode("; alloc ; if(!var) { exit; }"));
|
||||
|
|
Loading…
Reference in New Issue