Memory leak: Fixed false positives about deallocating pointer that has already been deallocated
This commit is contained in:
parent
f663d1da84
commit
666fc82011
|
@ -1166,7 +1166,9 @@ void CheckMemoryLeakClass::CheckMemoryLeak_CheckScope(const Token *Tok1, const c
|
||||||
tok2->str("use");
|
tok2->str("use");
|
||||||
else if (tok2->str() == "&use2" || tok2->str() == "use_")
|
else if (tok2->str() == "&use2" || tok2->str() == "use_")
|
||||||
tok2->str(";");
|
tok2->str(";");
|
||||||
else if (tok2->str() == "recursive" || tok2->str() == "dealloc_")
|
else if (tok2->str() == "recursive")
|
||||||
|
tok2->str("use");
|
||||||
|
else if (tok2->str() == "dealloc_")
|
||||||
tok2->str("dealloc");
|
tok2->str("dealloc");
|
||||||
else if (tok2->str() == "realloc")
|
else if (tok2->str() == "realloc")
|
||||||
{
|
{
|
||||||
|
|
|
@ -167,7 +167,8 @@ private:
|
||||||
TEST_CASE(dealloc_use_6);
|
TEST_CASE(dealloc_use_6);
|
||||||
|
|
||||||
// free a free'd pointer
|
// free a free'd pointer
|
||||||
TEST_CASE(freefree);
|
TEST_CASE(freefree1);
|
||||||
|
TEST_CASE(freefree2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1591,7 +1592,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void freefree()
|
void freefree1()
|
||||||
{
|
{
|
||||||
check("void foo()\n"
|
check("void foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -1602,6 +1603,17 @@ private:
|
||||||
ASSERT_EQUALS(std::string("[test.cpp:5]: Deallocating a deallocated pointer\n"), errout.str());
|
ASSERT_EQUALS(std::string("[test.cpp:5]: Deallocating a deallocated pointer\n"), errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void freefree2()
|
||||||
|
{
|
||||||
|
check("void foo()\n"
|
||||||
|
"{\n"
|
||||||
|
" FILE *fd = fopen(\"test.txt\", \"wb\");\n"
|
||||||
|
" fprintf(fd, \"test\");\n"
|
||||||
|
" fclose(fd);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS(std::string(""), errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestMemleak)
|
REGISTER_TEST(TestMemleak)
|
||||||
|
|
Loading…
Reference in New Issue