null pointer dereferencing: fixed another false positive (#485)

This commit is contained in:
Daniel Marjamäki 2009-07-20 19:59:55 +02:00
parent 05a1c50ff2
commit 0e208eb52f
2 changed files with 13 additions and 0 deletions

View File

@ -1051,6 +1051,9 @@ void CheckOther::nullPointer()
--indentlevel2; --indentlevel2;
} }
else if (Token::Match(tok2, "%varid% =", varid1))
break;
else if (tok2->str() == "if") else if (tok2->str() == "if")
{ {
if (Token::Match(tok2, "if ( !| %varid% )", varid1)) if (Token::Match(tok2, "if ( !| %varid% )", varid1))

View File

@ -488,6 +488,16 @@ private:
" ;\n" " ;\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
// reassign struct..
checkNullPointer("void foo(struct ABC *abc)\n"
"{\n"
" a = abc->a;\n"
" abc = abc->next;\n"
" if (!abc)\n"
" ;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
} }
void checkOldStylePointerCast(const char code[]) void checkOldStylePointerCast(const char code[])