Fixed another issue with #1154 (false positive: Data is allocated but not initialized)
This commit is contained in:
parent
24c5f4d53c
commit
b1e963fe2c
|
@ -1169,7 +1169,7 @@ static void parseFunctionCall(const Token &tok, std::list<const Token *> &var, u
|
||||||
var.push_back(tok.tokAt(2));
|
var.push_back(tok.tokAt(2));
|
||||||
else if (value == 0 && Token::Match(&tok, "memchr|memcmp|memcpy|memmove|memset|strcpy|printf|sprintf|snprintf"))
|
else if (value == 0 && Token::Match(&tok, "memchr|memcmp|memcpy|memmove|memset|strcpy|printf|sprintf|snprintf"))
|
||||||
var.push_back(tok.tokAt(2));
|
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));
|
var.push_back(tok.tokAt(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1552,6 +1552,13 @@ private:
|
||||||
|
|
||||||
if (Token::Match(&tok, "%var% ("))
|
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..
|
// parse usage..
|
||||||
{
|
{
|
||||||
std::list<const Token *> var;
|
std::list<const Token *> var;
|
||||||
|
|
|
@ -1349,6 +1349,13 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar("void foo()\n"
|
||||||
|
"{\n"
|
||||||
|
" ABC *abc = malloc(100);\n"
|
||||||
|
" free(abc);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
// struct..
|
// struct..
|
||||||
checkUninitVar("void f()\n"
|
checkUninitVar("void f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue