Merge branch 'memleak'
This commit is contained in:
commit
be0c79f36c
|
@ -523,6 +523,8 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
|
|||
int par = 1;
|
||||
int parlevel = 0;
|
||||
|
||||
const bool dot(tok->previous()->str() == ".");
|
||||
|
||||
for (; tok; tok = tok->next())
|
||||
{
|
||||
if (tok->str() == "(")
|
||||
|
@ -542,6 +544,9 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
|
|||
++par;
|
||||
if (varid > 0 && Token::Match(tok, "[,()] %varid% [,()]", varid))
|
||||
{
|
||||
if (dot)
|
||||
return "use";
|
||||
|
||||
const Token *ftok = _tokenizer->getFunctionTokenByName(funcname.c_str());
|
||||
if (!ftok)
|
||||
return "use";
|
||||
|
|
|
@ -271,6 +271,8 @@ private:
|
|||
// Unknown syntax
|
||||
TEST_CASE(unknownSyntax1);
|
||||
TEST_CASE(knownFunctions);
|
||||
|
||||
TEST_CASE(same_function_name);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2393,6 +2395,18 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: p\n", errout.str());
|
||||
}
|
||||
|
||||
void same_function_name()
|
||||
{
|
||||
check("void a(char *p)\n"
|
||||
"{ }\n"
|
||||
"void b()\n"
|
||||
"{\n"
|
||||
" char *p = malloc(10);\n"
|
||||
" abc.a(p);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
static TestMemleakInFunction testMemleakInFunction;
|
||||
|
|
Loading…
Reference in New Issue