memory leaks: fixed a TODO_ASSERT_EQUALS for a false positive

This commit is contained in:
Daniel Marjamäki 2009-09-28 22:41:45 +02:00
parent 949ad462c7
commit 1427f0a2c7
2 changed files with 30 additions and 1 deletions

View File

@ -2243,6 +2243,35 @@ void CheckMemoryLeakStructMember::check()
tok3 = tok3->next()->link();
}
// succeeded allocation
else if (Token::Match(tok3, "if ( %var% . %varid% ) {", structmemberid))
{
// goto the ")"
tok3 = tok3->next()->link();
// check if the variable is deallocated or returned..
unsigned int indentlevel4 = 0;
for (const Token *tok4 = tok3; tok4; tok4 = tok4->next())
{
if (tok4->str() == "{")
++indentlevel4;
else if (tok4->str() == "}")
{
--indentlevel4;
if (indentlevel4 == 0)
break;
}
else if (Token::Match(tok4, "free|kfree ( %var% . %varid% )", structmemberid))
{
break;
}
}
// was there a proper deallocation?
if (indentlevel4 > 0)
break;
}
// Returning from function..
else if (tok3->str() == "return")
{

View File

@ -2792,7 +2792,7 @@ private:
" free(abc->a);\n"
" free(abc);\n"
"}\n");
TODO_ASSERT_EQUALS("", errout.str());
ASSERT_EQUALS("", errout.str());
}
void ret()