Merge branch 'master' of git@github.com:danmar/cppcheck
This commit is contained in:
commit
0afe53c0bb
|
@ -486,6 +486,8 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
|
|||
if (Token::Match(tok, pattern.c_str()))
|
||||
{
|
||||
const Token *ftok = _tokenizer->GetFunctionTokenByName(funcname.c_str());
|
||||
if (!ftok)
|
||||
return "use";
|
||||
|
||||
// how many parameters does the function want?
|
||||
if (numpar != countParameters(ftok))
|
||||
|
@ -1161,7 +1163,7 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all)
|
|||
}
|
||||
|
||||
// Remove "if { dealloc ; callfunc ; } !!else"
|
||||
else if (Token::Match(tok2->next(), "if { dealloc|assign|use ; callfunc ; } !!else"))
|
||||
else if (Token::Match(tok2->next(), "if { dealloc|assign ; callfunc ; } !!else"))
|
||||
{
|
||||
Token::eraseTokens(tok2, tok2->tokAt(8));
|
||||
done = false;
|
||||
|
|
|
@ -255,6 +255,7 @@ private:
|
|||
TEST_CASE(unknownFunction2);
|
||||
TEST_CASE(unknownFunction3);
|
||||
TEST_CASE(unknownFunction4);
|
||||
TEST_CASE(unknownFunction5);
|
||||
|
||||
// VCL..
|
||||
TEST_CASE(vcl1);
|
||||
|
@ -1969,6 +1970,23 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: p\n", errout.str());
|
||||
}
|
||||
|
||||
void unknownFunction5()
|
||||
{
|
||||
check("static void foo()\n"
|
||||
"{\n"
|
||||
" char *p = NULL;\n"
|
||||
"\n"
|
||||
" if( a )\n"
|
||||
" p = malloc(100);\n"
|
||||
"\n"
|
||||
" if( a )\n"
|
||||
" {\n"
|
||||
" FREENULL(p);\n"
|
||||
" FREENULL();\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
void checkvcl(const char code[], const char _autoDealloc[])
|
||||
|
|
Loading…
Reference in New Issue