Fixed #4118 (False null-pointer warning when check is indirect)

This commit is contained in:
Daniel Marjamäki 2012-09-18 19:16:28 +02:00
parent a5bd41dd1c
commit ffd5c82b4f
2 changed files with 16 additions and 0 deletions

View File

@ -949,6 +949,14 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
break;
}
// Bailout for "if".
if (tok2->str() == "if") {
if (_settings->inconclusive)
inconclusive = true;
else
break;
}
if (Token::Match(tok2, "goto|continue|break|switch|for"))
break;

View File

@ -1475,6 +1475,14 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
// #4118 - second if
check("void f(char *p) {\n"
" int x = 1;\n"
" if (!p) x = 0;\n"
" if (x) *p = 0;\n"
"}");
ASSERT_EQUALS("", errout.str());
// #2582 - segmentation fault
check("if()");