Fixed #3267 (False positive: resource leak in vdr-xinelib)

This commit is contained in:
Daniel Marjamäki 2011-12-03 09:53:36 +01:00
parent 00bae586e9
commit fb3115a199
2 changed files with 7 additions and 2 deletions

View File

@ -1670,7 +1670,7 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
// Delete "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));
if (Token::simpleMatch(tok2->next(), "else"))
tok2->deleteNext();

View File

@ -705,7 +705,12 @@ private:
ASSERT_EQUALS("; loop use ;", simplifycode("; loop { loop loop use ; } ;"));
ASSERT_EQUALS("; }", simplifycode("; loop { if break ; break ; } ; }"));
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 ;"));