Fixed #2525 (False positive 'Possible null pointer dereference')
This commit is contained in:
parent
757c840633
commit
202c8eb4a0
|
@ -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;
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue