#5811 false postive: (error) Null pointer dereference
This commit is contained in:
parent
e04351ec33
commit
9dce9bddcb
|
@ -883,7 +883,7 @@ void CheckNullPointer::nullConstantDereference()
|
|||
else if (Token::simpleMatch(tok->previous(), ">> 0")) { // Only checking input stream operations is safe here, because otherwise 0 can be an integer as well
|
||||
const Token* tok2 = tok->previous(); // Find start of statement
|
||||
for (; tok2; tok2 = tok2->previous()) {
|
||||
if (Token::Match(tok2->previous(), ";|{|}|:"))
|
||||
if (Token::Match(tok2->previous(), ";|{|}|:|("))
|
||||
break;
|
||||
}
|
||||
if (Token::simpleMatch(tok2, "std :: cin"))
|
||||
|
@ -1064,4 +1064,3 @@ void CheckNullPointer::nullPointerDefaultArgError(const Token *tok, const std::s
|
|||
{
|
||||
reportError(tok, Severity::warning, "nullPointer", "Possible null pointer dereference if the default parameter value is used: " + varname);
|
||||
}
|
||||
|
||||
|
|
|
@ -2132,6 +2132,15 @@ private:
|
|||
" std::cout << i;\n" // Its no char* (#4240)
|
||||
"}", true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #5811 false postive: (error) Null pointer dereference
|
||||
check("using namespace std;\n"
|
||||
"std::string itoip(int ip) {\n"
|
||||
" stringstream out;\n"
|
||||
" out << ((ip >> 0) & 0xFF);\n"
|
||||
" return out.str();\n"
|
||||
"}n", true, "test.cpp", false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void functioncall() { // #3443 - function calls
|
||||
|
|
Loading…
Reference in New Issue