Fixed #2391 (cstdlib file and memory function check misbehavior)
This commit is contained in:
parent
320604f073
commit
b5876f00ff
|
@ -3075,6 +3075,11 @@ void CheckMemoryLeakNoVar::check()
|
||||||
if (Token::Match(tok3->tokAt(-2), "[(,;{}] %var% ("))
|
if (Token::Match(tok3->tokAt(-2), "[(,;{}] %var% ("))
|
||||||
{
|
{
|
||||||
const std::string functionName = tok3->strAt(-1);
|
const std::string functionName = tok3->strAt(-1);
|
||||||
|
if (functionName == "delete" ||
|
||||||
|
functionName == "free" ||
|
||||||
|
functionName == "fclose" ||
|
||||||
|
functionName == "realloc")
|
||||||
|
break;
|
||||||
if (CheckMemoryLeakInFunction::test_white_list(functionName))
|
if (CheckMemoryLeakInFunction::test_white_list(functionName))
|
||||||
{
|
{
|
||||||
functionCallLeak(tok2, tok2->strAt(1), functionName);
|
functionCallLeak(tok2, tok2->strAt(1), functionName);
|
||||||
|
|
|
@ -4413,6 +4413,11 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (error) Allocation with strdup, strcpy doesn't release it.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (error) Allocation with strdup, strcpy doesn't release it.\n", errout.str());
|
||||||
|
|
||||||
|
check("void x() {\n"
|
||||||
|
" free(malloc(10));\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
// user function..
|
// user function..
|
||||||
check("void set_error(const char *msg) {\n"
|
check("void set_error(const char *msg) {\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
Loading…
Reference in New Issue