Fixed #1442 (false positive: getting offset instead of dereferencing a null pointer)
This commit is contained in:
parent
dfe18dbb71
commit
0b2ad2164f
|
@ -1521,7 +1521,7 @@ private:
|
|||
dereference(foundError, checks, &tok);
|
||||
else if (Token::Match(tok.tokAt(-2), "return * %var%"))
|
||||
dereference(foundError, checks, &tok);
|
||||
else if (Token::Match(tok.next(), ". %var%"))
|
||||
else if (!Token::simpleMatch(tok.tokAt(-2), "& (") && Token::Match(tok.next(), ". %var%"))
|
||||
dereference(foundError, checks, &tok);
|
||||
else if (Token::Match(tok.previous(), "[;{}=+-/(,] %var% [ %any% ]"))
|
||||
dereference(foundError, checks, &tok);
|
||||
|
|
|
@ -1015,6 +1015,13 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkNullPointer("void get_offset(long &offset)\n"
|
||||
"{\n"
|
||||
" mystruct * temp; temp = 0;\n"
|
||||
" offset = (long)(&(temp->z));\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// function pointer..
|
||||
checkNullPointer("void foo()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue