Fixed #2525 (False positive 'Possible null pointer dereference')

This commit is contained in:
Daniel Marjamäki 2011-01-31 17:30:27 +01:00
parent 757c840633
commit 202c8eb4a0
2 changed files with 15 additions and 0 deletions

View File

@ -485,6 +485,12 @@ void CheckNullPointer::nullPointerByDeRefAndChec()
break;
}
if (tok1->str() == ")" && Token::simpleMatch(tok1->link()->previous(), "sizeof ("))
{
tok1 = tok1->link()->previous();
continue;
}
if (tok1->str() == "break")
break;

View File

@ -437,6 +437,15 @@ private:
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// #2525 - sizeof
check("void f() {\n"
" int *test = NULL;\n"
" int c = sizeof(test[0]);\n"
" if (!test)\n"
" ;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void nullpointer5()