Fixed #2900 (found memory leak in kernel p54usb and a false positive reported)
This commit is contained in:
parent
0c2f2e1c38
commit
5fc2a55bac
|
@ -1915,8 +1915,9 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove "if { dealloc ; callfunc ; } !!else"
|
// Remove "if { dealloc ; callfunc ; } !!else|return"
|
||||||
else if (Token::Match(tok2->next(), "if { dealloc|assign ; callfunc ; } !!else"))
|
else if (Token::Match(tok2->next(), "if { dealloc|assign ; callfunc ; }") &&
|
||||||
|
!Token::Match(tok2->tokAt(8), "else|return"))
|
||||||
{
|
{
|
||||||
Token::eraseTokens(tok2, tok2->tokAt(8));
|
Token::eraseTokens(tok2, tok2->tokAt(8));
|
||||||
done = false;
|
done = false;
|
||||||
|
|
|
@ -738,6 +738,10 @@ private:
|
||||||
ASSERT_EQUALS("dealloc ; alloc ; return ; }", simplifycode("while1 { dealloc ; alloc ; } callfunc ; return ; }"));
|
ASSERT_EQUALS("dealloc ; alloc ; return ; }", simplifycode("while1 { dealloc ; alloc ; } callfunc ; return ; }"));
|
||||||
ASSERT_EQUALS("; }", simplifycode("loop callfunc ; }"));
|
ASSERT_EQUALS("; }", simplifycode("loop callfunc ; }"));
|
||||||
|
|
||||||
|
// #2900 - don't report false positive
|
||||||
|
ASSERT_EQUALS("; alloc ; if { if { dealloc ; callfunc ; } return ; } dealloc ; }",
|
||||||
|
simplifycode("; alloc ; if { if { dealloc ; callfunc ; } return ; } dealloc ; }"));
|
||||||
|
|
||||||
// exit..
|
// exit..
|
||||||
ASSERT_EQUALS("; exit ;", simplifycode("; alloc; exit;"));
|
ASSERT_EQUALS("; exit ;", simplifycode("; alloc; exit;"));
|
||||||
ASSERT_EQUALS("; exit ;", simplifycode("; alloc; if { loop ; } dealloc; exit;"));
|
ASSERT_EQUALS("; exit ;", simplifycode("; alloc; if { loop ; } dealloc; exit;"));
|
||||||
|
|
Loading…
Reference in New Issue