Fix #299 (Memory leak not detected when parameters contain ::)
http://apps.sourceforge.net/trac/cppcheck/ticket/299
This commit is contained in:
parent
bce4488475
commit
e6017ad54b
|
@ -1384,6 +1384,7 @@ void CheckMemoryLeakClass::CheckMemoryLeak_CheckScope(const Token *Tok1, const c
|
|||
void CheckMemoryLeakClass::CheckMemoryLeak_InFunction()
|
||||
{
|
||||
bool classmember = false;
|
||||
bool beforeParameters = false;
|
||||
bool infunc = false;
|
||||
int indentlevel = 0;
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
|
@ -1400,11 +1401,17 @@ void CheckMemoryLeakClass::CheckMemoryLeak_InFunction()
|
|||
if (Token::simpleMatch(tok, ") {"))
|
||||
infunc = true;
|
||||
|
||||
else if (tok->str() == "::")
|
||||
else if (tok->str() == "(")
|
||||
beforeParameters = false;
|
||||
|
||||
else if (tok->str() == "::" && beforeParameters)
|
||||
classmember = true;
|
||||
|
||||
else if (Token::Match(tok, "[;}]"))
|
||||
{
|
||||
infunc = classmember = false;
|
||||
beforeParameters = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Declare a local variable => Check
|
||||
|
|
|
@ -2165,7 +2165,7 @@ private:
|
|||
|
||||
std::string err(errout.str());
|
||||
|
||||
TODO_ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Memory leak: out\n"), err);
|
||||
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Memory leak: out\n"), err);
|
||||
}
|
||||
|
||||
void strndup_function()
|
||||
|
|
Loading…
Reference in New Issue