Fixed #4118 (False null-pointer warning when check is indirect)
This commit is contained in:
parent
a5bd41dd1c
commit
ffd5c82b4f
|
@ -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;
|
||||
|
||||
|
|
|
@ -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()");
|
||||
|
||||
|
|
Loading…
Reference in New Issue