Fixed #2285 (False Positive: memory leak)

This commit is contained in:
Daniel Marjamäki 2010-12-08 21:02:02 +01:00
parent bc30c7d23b
commit cad9c5f232
2 changed files with 4 additions and 2 deletions

View File

@ -1847,10 +1847,10 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
}
// Reduce "while1 continue| ;" => "use ;"
if (Token::Match(tok2, "while1 continue| ;"))
if (Token::Match(tok2, "while1 if| continue| ;"))
{
tok2->str("use");
if (tok2->strAt(1) == "continue")
while (tok2->strAt(1) != ";")
tok2->deleteNext();
done = false;
}

View File

@ -668,6 +668,8 @@ private:
ASSERT_EQUALS(";", simplifycode("; loop { if { continue ; } else { if continue ; } }"));
ASSERT_EQUALS(";", simplifycode("; loop { { if continue ; if continue ; } }"));
ASSERT_EQUALS(";", simplifycode("; while1 { if { dealloc ; return ; } if { if { continue ; } } }"));
// scope..
// current result - ok
ASSERT_EQUALS("; assign ; dealloc ; if alloc ; }", simplifycode("; assign ; { dealloc ; if alloc ; } }"));