Fixed #2413 (fflush() with NULL argument is valid.)
This commit is contained in:
parent
03a484554c
commit
d1854e330b
|
@ -86,7 +86,7 @@ void CheckNullPointer::parseFunctionCall(const Token &tok, std::list<const Token
|
||||||
var.push_back(tok.tokAt(2));
|
var.push_back(tok.tokAt(2));
|
||||||
else if (value == 0 && Token::Match(&tok, "memchr|memcmp|memcpy|memmove|memset|strcpy|printf|sprintf|snprintf"))
|
else if (value == 0 && Token::Match(&tok, "memchr|memcmp|memcpy|memmove|memset|strcpy|printf|sprintf|snprintf"))
|
||||||
var.push_back(tok.tokAt(2));
|
var.push_back(tok.tokAt(2));
|
||||||
else if (Token::simpleMatch(&tok, "fflush"))
|
else if (value != 0 && Token::simpleMatch(&tok, "fflush"))
|
||||||
var.push_back(tok.tokAt(2));
|
var.push_back(tok.tokAt(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -821,6 +821,13 @@ private:
|
||||||
" strcpy(p, \"abcd\");\n"
|
" strcpy(p, \"abcd\");\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (error) Null pointer dereference\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (error) Null pointer dereference\n", errout.str());
|
||||||
|
|
||||||
|
// Ticket #2413 - it's ok to pass NULL to fflush
|
||||||
|
check("void foo() {\n"
|
||||||
|
" fflush(NULL);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue