Fixed #253 (MemoryLeakInClass: False positive when memory is released in function, which is called from destructor)
This commit is contained in:
parent
39c9a2a4da
commit
26a81e82cc
|
@ -2155,10 +2155,6 @@ void CheckMemoryLeakInClass::variable(const char classname[], const Token *tokVa
|
|||
if (indent == 0)
|
||||
continue;
|
||||
|
||||
// Function call in destructor.. possible deallocation
|
||||
if (destructor && Token::Match(tok, "[{};] %var% ("))
|
||||
deallocInDestructor = true;
|
||||
|
||||
// Deallocate..
|
||||
const char *varnames[3] = { "var", 0, 0 };
|
||||
varnames[0] = varname;
|
||||
|
@ -2187,6 +2183,17 @@ void CheckMemoryLeakInClass::variable(const char classname[], const Token *tokVa
|
|||
|
||||
Dealloc = dealloc;
|
||||
}
|
||||
|
||||
// Function call in destructor .. possible deallocation
|
||||
else if (destructor && Token::Match(tok->previous(), "[{};] %var% ("))
|
||||
{
|
||||
if (!std::bsearch(tok->strAt(0), call_func_white_list,
|
||||
sizeof(call_func_white_list) / sizeof(call_func_white_list[0]),
|
||||
sizeof(call_func_white_list[0]), call_func_white_list_compare))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2564,7 +2564,7 @@ private:
|
|||
" }\n"
|
||||
"}\n", true);
|
||||
|
||||
TODO_ASSERT_EQUALS("", errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void class4()
|
||||
|
@ -2799,7 +2799,7 @@ private:
|
|||
"{\n"
|
||||
" delete tok;\n"
|
||||
"}\n", true);
|
||||
TODO_ASSERT_EQUALS("", errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Global function
|
||||
check("void deleteTokens(int *tok)\n"
|
||||
|
@ -2826,7 +2826,7 @@ private:
|
|||
" deleteTokens(_tokens);\n"
|
||||
" _tokens = 0;\n"
|
||||
"}\n", true);
|
||||
TODO_ASSERT_EQUALS("", errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue