Fixed #1712 (False negative: dereferencing uninitialized pointer)
This commit is contained in:
parent
dc34a1b3ff
commit
d3c20cac81
|
@ -244,17 +244,21 @@ static void checkExecutionPaths_(const Token *tok, std::list<ExecutionPath *> &c
|
|||
{
|
||||
std::list<ExecutionPath *>::const_iterator it;
|
||||
for (it = checks.begin(); it != checks.end(); ++it)
|
||||
{
|
||||
if ((*it)->varId != 0)
|
||||
{
|
||||
c.push_back((*it)->copy());
|
||||
if ((*it)->varId != 0)
|
||||
countif2.insert((*it)->varId);
|
||||
}
|
||||
}
|
||||
}
|
||||
checkExecutionPaths_(tok->next(), c);
|
||||
while (!c.empty())
|
||||
{
|
||||
if (c.back()->varId == 0)
|
||||
{
|
||||
c.pop_back();
|
||||
continue;
|
||||
}
|
||||
|
||||
bool duplicate = false;
|
||||
std::list<ExecutionPath *>::const_iterator it;
|
||||
for (it = checks.begin(); it != checks.end(); ++it)
|
||||
|
|
|
@ -1411,6 +1411,15 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkNullPointer("void f(int a)\n"
|
||||
"{\n"
|
||||
" if (a) {\n"
|
||||
" char *p;\n"
|
||||
" *p = 0;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized variable: p\n", errout.str());
|
||||
|
||||
// +=
|
||||
checkUninitVar("void f()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue