Fixed #3267 (False positive: resource leak in vdr-xinelib)
This commit is contained in:
parent
00bae586e9
commit
fb3115a199
|
@ -1670,7 +1670,7 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
||||||
|
|
||||||
// Delete "if { dealloc|assign|use ; return ; }"
|
// Delete "if { dealloc|assign|use ; return ; }"
|
||||||
else if (Token::Match(tok2, "[;{}] if { dealloc|assign|use ; return ; }") &&
|
else if (Token::Match(tok2, "[;{}] if { dealloc|assign|use ; return ; }") &&
|
||||||
!Token::findsimplematch(tok, "if alloc ;")) {
|
!Token::findmatch(tok, "if {| alloc ;")) {
|
||||||
Token::eraseTokens(tok2, tok2->tokAt(8));
|
Token::eraseTokens(tok2, tok2->tokAt(8));
|
||||||
if (Token::simpleMatch(tok2->next(), "else"))
|
if (Token::simpleMatch(tok2->next(), "else"))
|
||||||
tok2->deleteNext();
|
tok2->deleteNext();
|
||||||
|
|
|
@ -705,7 +705,12 @@ private:
|
||||||
ASSERT_EQUALS("; loop use ;", simplifycode("; loop { loop loop use ; } ;"));
|
ASSERT_EQUALS("; loop use ;", simplifycode("; loop { loop loop use ; } ;"));
|
||||||
ASSERT_EQUALS("; }", simplifycode("; loop { if break ; break ; } ; }"));
|
ASSERT_EQUALS("; }", simplifycode("; loop { if break ; break ; } ; }"));
|
||||||
ASSERT_EQUALS("; }", simplifycode("; loop { if continue ; if continue ; } ; }"));
|
ASSERT_EQUALS("; }", simplifycode("; loop { if continue ; if continue ; } ; }"));
|
||||||
ASSERT_EQUALS("; loop if alloc ; if { dealloc ; return ; } }", simplifycode("; loop { if alloc ; } if { dealloc ; return ; } }"));
|
{
|
||||||
|
// ticket #3267
|
||||||
|
const char expected[] = "; loop if alloc ; if { dealloc ; return ; } }";
|
||||||
|
ASSERT_EQUALS(expected, simplifycode("; loop { if alloc ; } if { dealloc ; return ; } }"));
|
||||||
|
ASSERT_EQUALS(expected, simplifycode("; loop { if { alloc ; if(!var) { return ; } } } if { dealloc ; return ; } }"));
|
||||||
|
}
|
||||||
|
|
||||||
ASSERT_EQUALS("; alloc ;", simplifycode("; alloc ; while(!var) alloc ;"));
|
ASSERT_EQUALS("; alloc ;", simplifycode("; alloc ; while(!var) alloc ;"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue