Fixed #2437 (false positive: possible null pointer dereference: tok2)

This commit is contained in:
Daniel Marjamäki 2011-01-08 17:16:52 +01:00
parent 67a1c6817b
commit 68beffca04
2 changed files with 9 additions and 1 deletions

View File

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

View File

@ -397,6 +397,14 @@ private:
" ;\n" " ;\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); 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() void nullpointer5()