Fixed #2443 (Possible null pointer dereference: xxx - otherwise it is redundant to check if xxx is null at line)

This commit is contained in:
Daniel Marjamäki 2011-01-10 19:57:26 +01:00
parent 2d92f1ff6a
commit 9658e2299d
2 changed files with 17 additions and 0 deletions

View File

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

View File

@ -405,6 +405,18 @@ private:
" ;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("BOOL GotoFlyAnchor()\n" // #2243
"{\n"
" const SwFrm* pFrm = GetCurrFrm();\n"
" do {\n"
" pFrm = pFrm->GetUpper();\n"
" } while( pFrm && !pFrm->IsFlyFrm() );\n"
"\n"
" if( !pFrm )\n"
" return FALSE;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void nullpointer5()