Fixed #2338 (False positive: Deallocating a deallocated pointer)

This commit is contained in:
Daniel Marjamäki 2010-12-22 08:24:50 +01:00
parent 6951c32683
commit f392dbef95
2 changed files with 2 additions and 1 deletions

View File

@ -4102,7 +4102,7 @@ void Tokenizer::removeRedundantAssignment()
const Token * const end = tok->next()->link(); const Token * const end = tok->next()->link();
for (Token *tok2 = tok->next(); tok2 && tok2 != end; tok2 = tok2->next()) for (Token *tok2 = tok->next(); tok2 && tok2 != end; tok2 = tok2->next())
{ {
if (Token::Match(tok2, "[;{}] %type% * %var% ;")) if (Token::Match(tok2, "[;{}] %type% * %var% ;") && tok2->strAt(1) != "return")
{ {
tok2 = tok2->tokAt(3); tok2 = tok2->tokAt(3);
localvars.insert(tok2->varId()); localvars.insert(tok2->varId());

View File

@ -4348,6 +4348,7 @@ private:
{ {
ASSERT_EQUALS("void f ( ) { ; int * q ; }", tokenizeAndStringify("void f() { int *p, *q; p = q; }", true)); ASSERT_EQUALS("void f ( ) { ; int * q ; }", tokenizeAndStringify("void f() { int *p, *q; p = q; }", true));
ASSERT_EQUALS("void f ( ) { ; int * q ; }", tokenizeAndStringify("void f() { int *p = 0, *q; p = q; }", true)); ASSERT_EQUALS("void f ( ) { ; int * q ; }", tokenizeAndStringify("void f() { int *p = 0, *q; p = q; }", true));
ASSERT_EQUALS("int f ( int * x ) { return * x ; }", tokenizeAndStringify("int f(int *x) { return *x; }", true));
} }
void removedeclspec() void removedeclspec()