Fixed #1397 (false positive: Memory leak in while loop)

This commit is contained in:
Daniel Marjamäki 2010-02-26 22:14:56 +01:00
parent 9b6336013b
commit ce0131a1e6
2 changed files with 4 additions and 0 deletions

View File

@ -2978,6 +2978,8 @@ bool Tokenizer::simplifyTokenList()
simplifyNestedStrcat();
simplifyWhile0();
simplifyIfAssign(); // could be affected by simplifyIfNot
for (Token *tok = _tokens; tok; tok = tok->next())
{
if (Token::Match(tok, "case %any% : %var%"))

View File

@ -1700,6 +1700,8 @@ private:
tok("struct hfs_bnode *node;"
"struct hfs_btree *tree;"
"while ((node = tree->node_hash[i++])) { }"));
ASSERT_EQUALS("char * s ; s = new char [ 10 ] ; while ( ! s ) { s = new char [ 10 ] ; }",
tok("char *s; while (0 == (s=new char[10])) { }"));
}