Fixed #2437 (false positive: possible null pointer dereference: tok2)
This commit is contained in:
parent
67a1c6817b
commit
68beffca04
|
@ -461,7 +461,7 @@ void CheckNullPointer::nullPointerByDeRefAndChec()
|
|||
break;
|
||||
}
|
||||
|
||||
if (tok1->varId() == varid)
|
||||
if (tok1->varId() == varid && !Token::Match(tok1->previous(), "[?:]"))
|
||||
{
|
||||
// unknown : this is set by isPointerDeRef if it is
|
||||
// uncertain
|
||||
|
|
|
@ -397,6 +397,14 @@ private:
|
|||
" ;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(struct ABC *abc)\n"
|
||||
"{\n"
|
||||
" abc = abc ? abc->next : 0;\n"
|
||||
" if (!abc)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void nullpointer5()
|
||||
|
|
Loading…
Reference in New Issue