Memory leaks: fixed a todo testcase

This commit is contained in:
Daniel Marjamäki 2009-09-01 19:33:17 +02:00
parent 59a4a36fe1
commit 7ba244cf45
2 changed files with 7 additions and 4 deletions

View File

@ -1633,6 +1633,11 @@ const Token *CheckMemoryLeakInFunction::findleak(const Token *tokens, bool all)
return result->tokAt(2); return result->tokAt(2);
} }
if ((result = Token::findmatch(tokens, "alloc ; if assign ;")) != NULL)
{
return result->tokAt(3);
}
if ((result = Token::findmatch(tokens, "alloc ; }")) != NULL) if ((result = Token::findmatch(tokens, "alloc ; }")) != NULL)
{ {
if (result->tokAt(3) == NULL) if (result->tokAt(3) == NULL)

View File

@ -558,7 +558,8 @@ private:
// assign.. // assign..
ASSERT_EQUALS(2, dofindleak("alloc;\n assign;\n dealloc;")); ASSERT_EQUALS(2, dofindleak("alloc;\n assign;\n dealloc;"));
ASSERT_EQUALS(-1, dofindleak("alloc;\n if(!var) assign;\n dealloc;")); ASSERT_EQUALS(-1, dofindleak("alloc;\n if(!var) assign;\n dealloc;"));
ASSERT_EQUALS(2, dofindleak("alloc;\n if assign;\n dealloc;"));
// loop.. // loop..
ASSERT_EQUALS(1, dofindleak("; loop { alloc ; if break; dealloc ; }")); ASSERT_EQUALS(1, dofindleak("; loop { alloc ; if break; dealloc ; }"));
@ -570,9 +571,6 @@ private:
ASSERT_EQUALS(-1, dofindleak("; alloc;\n if { dealloc; }\n ;")); ASSERT_EQUALS(-1, dofindleak("; alloc;\n if { dealloc; }\n ;"));
TODO_ASSERT_EQUALS(3, dofindleak("; alloc;\n if { dealloc; }\n ;")); TODO_ASSERT_EQUALS(3, dofindleak("; alloc;\n if { dealloc; }\n ;"));
ASSERT_EQUALS(-1, dofindleak("alloc;\n if assign;\n dealloc;"));
TODO_ASSERT_EQUALS(2, dofindleak("alloc;\n if assign;\n dealloc;"));
ASSERT_EQUALS(-1, dofindleak("alloc; if { return use; }")); ASSERT_EQUALS(-1, dofindleak("alloc; if { return use; }"));
TODO_ASSERT_EQUALS(1, dofindleak("alloc; if { return use; }")); TODO_ASSERT_EQUALS(1, dofindleak("alloc; if { return use; }"));
ASSERT_EQUALS(-1, dofindleak("alloc; if { dealloc; return; }")); ASSERT_EQUALS(-1, dofindleak("alloc; if { dealloc; return; }"));