Fixed another issue with #1154 (false positive: Data is allocated but not initialized)

This commit is contained in:
Daniel Marjamäki 2009-12-27 18:00:43 +01:00
parent 24c5f4d53c
commit b1e963fe2c
2 changed files with 15 additions and 1 deletions

View File

@ -1169,7 +1169,7 @@ static void parseFunctionCall(const Token &tok, std::list<const Token *> &var, u
var.push_back(tok.tokAt(2));
else if (value == 0 && Token::Match(&tok, "memchr|memcmp|memcpy|memmove|memset|strcpy|printf|sprintf|snprintf"))
var.push_back(tok.tokAt(2));
else if (Token::Match(&tok, "free|kfree|fclose|fflush"))
else if (Token::simpleMatch(&tok, "fflush"))
var.push_back(tok.tokAt(2));
}
@ -1552,6 +1552,13 @@ private:
if (Token::Match(&tok, "%var% ("))
{
// deallocate pointer
if (Token::Match(&tok, "free|kfree|fclose ( %var% )"))
{
dealloc_pointer(foundError, checks, tok.tokAt(2));
return tok.tokAt(3);
}
// parse usage..
{
std::list<const Token *> var;

View File

@ -1349,6 +1349,13 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo()\n"
"{\n"
" ABC *abc = malloc(100);\n"
" free(abc);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// struct..
checkUninitVar("void f()\n"
"{\n"