Fixed #853 (False positive: memory leak for member variable with unknown function)
This commit is contained in:
parent
ee7ad272d6
commit
8a6f4254e0
|
@ -2495,8 +2495,8 @@ void CheckMemoryLeakInClass::variable(const std::string &classname, const Token
|
|||
Dealloc = dealloc;
|
||||
}
|
||||
|
||||
// Function call in destructor .. possible deallocation
|
||||
else if (destructor && Token::Match(tok->previous(), "[{};] %var% ("))
|
||||
// Function call .. possible deallocation
|
||||
else if (Token::Match(tok->previous(), "[{};] %var% ("))
|
||||
{
|
||||
if (!std::bsearch(tok->str().c_str(), call_func_white_list,
|
||||
sizeof(call_func_white_list) / sizeof(call_func_white_list[0]),
|
||||
|
|
|
@ -2851,6 +2851,7 @@ private:
|
|||
TEST_CASE(class15);
|
||||
TEST_CASE(class16);
|
||||
TEST_CASE(class17);
|
||||
TEST_CASE(class18);
|
||||
|
||||
TEST_CASE(staticvar);
|
||||
|
||||
|
@ -3223,6 +3224,23 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void class18()
|
||||
{
|
||||
// Ticket #853
|
||||
check("class A : public x\n"
|
||||
"{\n"
|
||||
"public:\n"
|
||||
" A()\n"
|
||||
" {\n"
|
||||
" a = new char[10];\n"
|
||||
" foo(a);\n"
|
||||
" }\n"
|
||||
"private:\n"
|
||||
" char *a;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void staticvar()
|
||||
{
|
||||
check("class A\n"
|
||||
|
|
Loading…
Reference in New Issue