Fixed #554 (resource leak false positive)
This commit is contained in:
parent
706ba34a6d
commit
9e348ca739
|
@ -1241,7 +1241,7 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce "alloc|dealloc|use ; exit ;" => "; exit ;"
|
// Reduce "alloc|dealloc|use ; exit ;" => "; exit ;"
|
||||||
if (Token::Match(tok2, "alloc|dealloc|use ; exit ;"))
|
if (Token::Match(tok2, "alloc|dealloc|use|callfunc ; exit ;"))
|
||||||
{
|
{
|
||||||
tok2->deleteThis();
|
tok2->deleteThis();
|
||||||
done = false;
|
done = false;
|
||||||
|
|
|
@ -266,6 +266,7 @@ private:
|
||||||
TEST_CASE(exit2);
|
TEST_CASE(exit2);
|
||||||
TEST_CASE(exit3);
|
TEST_CASE(exit3);
|
||||||
TEST_CASE(exit4);
|
TEST_CASE(exit4);
|
||||||
|
TEST_CASE(exit5);
|
||||||
TEST_CASE(stdstring);
|
TEST_CASE(stdstring);
|
||||||
|
|
||||||
TEST_CASE(strndup_function);
|
TEST_CASE(strndup_function);
|
||||||
|
@ -2164,6 +2165,20 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:8]: (error) Memory leak: p\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:8]: (error) Memory leak: p\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void exit5()
|
||||||
|
{
|
||||||
|
check("void f()\n"
|
||||||
|
"{\n"
|
||||||
|
" char *p = malloc(100);\n"
|
||||||
|
" if (p)\n"
|
||||||
|
" {\n"
|
||||||
|
" xyz();\n"
|
||||||
|
" exit(0);\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void stdstring()
|
void stdstring()
|
||||||
|
|
Loading…
Reference in New Issue