Fixed #2300 (false positive: possible nullpointer dereference)
This commit is contained in:
parent
49ee1533d9
commit
0cebcc8fa9
|
@ -497,8 +497,8 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
|
|||
continue;
|
||||
}
|
||||
|
||||
// abort function..
|
||||
if (Token::simpleMatch(tok2, ") ; }") &&
|
||||
// calling unknown function (abort/init)..
|
||||
if (Token::simpleMatch(tok2, ") ;") &&
|
||||
Token::Match(tok2->link()->tokAt(-2), "[;{}] %var% ("))
|
||||
{
|
||||
break;
|
||||
|
|
|
@ -747,6 +747,16 @@ private:
|
|||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// ticket: #2300 - calling unknown function that may initialize the pointer
|
||||
check("Fred *fred;\n"
|
||||
"void a() {\n"
|
||||
" if (!fred) {\n"
|
||||
" initfred();\n"
|
||||
" fred->x = 0;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue