Fixed #2463 (false positive: possible nullpointer dereference)

This commit is contained in:
Daniel Marjamäki 2011-01-15 12:09:36 +01:00
parent 97d0755750
commit 6edf35ebf5
2 changed files with 23 additions and 0 deletions

View File

@ -466,6 +466,9 @@ void CheckNullPointer::nullPointerByDeRefAndChec()
break;
}
if (tok1->str() == "break")
break;
if (tok1->varId() == varid && !Token::Match(tok1->previous(), "[?:]"))
{
// unknown : this is set by isPointerDeRef if it is

View File

@ -417,6 +417,26 @@ private:
" return FALSE;\n"
"}\n");
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()