memory leaks: fixed a TODO_ASSERT_EQUALS for a false positive
This commit is contained in:
parent
949ad462c7
commit
1427f0a2c7
|
@ -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")
|
||||
{
|
||||
|
|
|
@ -2792,7 +2792,7 @@ private:
|
|||
" free(abc->a);\n"
|
||||
" free(abc);\n"
|
||||
"}\n");
|
||||
TODO_ASSERT_EQUALS("", errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void ret()
|
||||
|
|
Loading…
Reference in New Issue