Fixed #2635 (False positive: resource leak)

This commit is contained in:
Daniel Marjamäki 2011-03-09 19:53:59 +01:00
parent e588f20e76
commit be33f6b945
2 changed files with 6 additions and 2 deletions

View File

@ -1964,8 +1964,8 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
} }
else else
{ {
// remove the "if* ;" // remove the "if*"
Token::eraseTokens(tok2, tok2->tokAt(3)); Token::eraseTokens(tok2, tok2->tokAt(2));
} }
done = false; done = false;
} }

View File

@ -727,6 +727,10 @@ private:
// use ; dealloc ; // use ; dealloc ;
ASSERT_EQUALS("; alloc ; use ; if return ; dealloc ;", simplifycode("; alloc ; use ; if { return ; } dealloc ;")); ASSERT_EQUALS("; alloc ; use ; if return ; dealloc ;", simplifycode("; alloc ; use ; if { return ; } dealloc ;"));
// #2635 - false negative
ASSERT_EQUALS("; alloc ; return use ; }",
simplifycode("; alloc ; if(!var) { loop { ifv { } } alloc ; } return use; }"));
} }