Fixed #2130 (Invalid possible NULL pointer dereference, etc.)
This commit is contained in:
parent
bdd6d6d53d
commit
893f7fa347
|
@ -2569,6 +2569,13 @@ void CheckOther::nullPointerByCheckAndDeRef()
|
|||
break;
|
||||
}
|
||||
|
||||
// abort function..
|
||||
if (Token::Match(tok2->previous(), "[;{}] %var% (") &&
|
||||
Token::simpleMatch(tok2->next()->link(), ") ; }"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (tok2->varId() == varid)
|
||||
{
|
||||
if (Token::Match(tok2->previous(), "[;{}=] %var% = 0 ;"))
|
||||
|
|
|
@ -1169,6 +1169,15 @@ private:
|
|||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkNullPointer("void foo(char *p) {\n"
|
||||
" if (!p) {\n"
|
||||
" abort();\n"
|
||||
" }\n"
|
||||
" *p = 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
}
|
||||
|
||||
void checkUninitVar(const char code[])
|
||||
|
|
Loading…
Reference in New Issue