Fixed #2065 (false positive: memory leak)

This commit is contained in:
Daniel Marjamäki 2010-09-27 17:53:10 +02:00
parent 6a52538a9a
commit 80069f016e
2 changed files with 4 additions and 3 deletions

View File

@ -2134,9 +2134,9 @@ const Token *CheckMemoryLeakInFunction::findleak(const Token *tokens)
return result->tokAt(2); return result->tokAt(2);
} }
if ((result = Token::findmatch(tokens, "alloc ; if assign ;")) != NULL) if ((result = Token::findmatch(tokens, "; alloc ; if assign ;")) != NULL)
{ {
return result->tokAt(3); return result->tokAt(4);
} }
if (((result = Token::findmatch(tokens, "; alloc ; if dealloc ; }")) != NULL) && if (((result = Token::findmatch(tokens, "; alloc ; if dealloc ; }")) != NULL) &&

View File

@ -812,6 +812,7 @@ private:
ASSERT_EQUALS(2, dofindleak("if alloc;\n return;")); ASSERT_EQUALS(2, dofindleak("if alloc;\n return;"));
ASSERT_EQUALS(notfound, dofindleak("if alloc;\n return use;")); ASSERT_EQUALS(notfound, dofindleak("if alloc;\n return use;"));
ASSERT_EQUALS(notfound, dofindleak("if alloc;\n use;")); ASSERT_EQUALS(notfound, dofindleak("if alloc;\n use;"));
ASSERT_EQUALS(notfound, dofindleak("if alloc;\n if assign;\n if dealloc; }"));
// if.. // if..
ASSERT_EQUALS(notfound, dofindleak("alloc; ifv dealloc;")); ASSERT_EQUALS(notfound, dofindleak("alloc; ifv dealloc;"));
@ -832,7 +833,7 @@ private:
// assign.. // assign..
ASSERT_EQUALS(2, dofindleak("alloc;\n assign;\n dealloc;")); ASSERT_EQUALS(2, dofindleak("alloc;\n assign;\n dealloc;"));
ASSERT_EQUALS(notfound, dofindleak("alloc;\n if(!var) assign;\n dealloc;")); ASSERT_EQUALS(notfound, dofindleak("alloc;\n if(!var) assign;\n dealloc;"));
ASSERT_EQUALS(2, dofindleak("alloc;\n if assign;\n dealloc;")); ASSERT_EQUALS(2, dofindleak(";alloc;\n if assign;\n dealloc;"));
// loop.. // loop..
TODO_ASSERT_EQUALS(1, dofindleak("; loop { alloc ; if break; dealloc ; }")); TODO_ASSERT_EQUALS(1, dofindleak("; loop { alloc ; if break; dealloc ; }"));