Fixed #2463 (false positive: possible nullpointer dereference)
This commit is contained in:
parent
97d0755750
commit
6edf35ebf5
|
@ -466,6 +466,9 @@ void CheckNullPointer::nullPointerByDeRefAndChec()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tok1->str() == "break")
|
||||||
|
break;
|
||||||
|
|
||||||
if (tok1->varId() == varid && !Token::Match(tok1->previous(), "[?:]"))
|
if (tok1->varId() == varid && !Token::Match(tok1->previous(), "[?:]"))
|
||||||
{
|
{
|
||||||
// unknown : this is set by isPointerDeRef if it is
|
// unknown : this is set by isPointerDeRef if it is
|
||||||
|
|
|
@ -417,6 +417,26 @@ private:
|
||||||
" return FALSE;\n"
|
" return FALSE;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// Ticket #2463
|
||||||
|
check("struct A \n"
|
||||||
|
"{\n"
|
||||||
|
" B* W;\n"
|
||||||
|
"\n"
|
||||||
|
" void f() {\n"
|
||||||
|
" switch (InData) {\n"
|
||||||
|
" case 2:\n"
|
||||||
|
" if (!W) return;\n"
|
||||||
|
" W->foo();\n"
|
||||||
|
" break;\n"
|
||||||
|
" case 3:\n"
|
||||||
|
" f();\n"
|
||||||
|
" if (!W) return;\n"
|
||||||
|
" break;\n"
|
||||||
|
" }\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void nullpointer5()
|
void nullpointer5()
|
||||||
|
|
Loading…
Reference in New Issue