Fixed #2141 (false positive: possible null pointer dereference)

This commit is contained in:
Daniel Marjamäki 2010-10-27 19:42:47 +02:00
parent fd153eac02
commit fc98bcdcb2
2 changed files with 9 additions and 0 deletions

View File

@ -2543,6 +2543,8 @@ void CheckOther::nullPointerByCheckAndDeRef()
{
bool null = true;
const unsigned int varid(tok->tokAt(3)->varId());
if (varid == 0)
continue;
unsigned int indentlevel = 1;
for (const Token *tok2 = tok->tokAt(6); tok2; tok2 = tok2->next())
{

View File

@ -1197,6 +1197,13 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
checkNullPointer("void foo() {\n"
" if (!p) {\n"
" switch (x) { }\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void checkUninitVar(const char code[])