CheckMemoryLeak: Removed false positives
This commit is contained in:
parent
a4486fb883
commit
4094f6bc6e
|
@ -210,6 +210,11 @@ static void CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const char varname[]
|
|||
if ( Match( tok, "[=,(] ( %type% %type% * ) %var1% [,);]", varnames ) )
|
||||
return;
|
||||
|
||||
// Used. Todo: check if "p" is the first member in the struct.
|
||||
// p = &var1->p;
|
||||
if ( Match( tok, "= & %var1% . %var% ;", varnames ) )
|
||||
return;
|
||||
|
||||
// Linux lists..
|
||||
if ( Match( tok, "%var% ( & %var1% .", varnames ) )
|
||||
{
|
||||
|
|
18
tests.cpp
18
tests.cpp
|
@ -637,10 +637,10 @@ static void memleak_in_function()
|
|||
" char *str = strdup(\"hello\");\n"
|
||||
" char *str2 = (char *)str;\n"
|
||||
" free(str2);\n"
|
||||
"}\n";
|
||||
"}\n";
|
||||
check( CheckMemoryLeak, __LINE__, test17, "" );
|
||||
|
||||
|
||||
|
||||
const char test18[] = "static void f()\n"
|
||||
"{\n"
|
||||
" char *str;\n"
|
||||
|
@ -650,6 +650,20 @@ static void memleak_in_function()
|
|||
"}\n";
|
||||
check( CheckMemoryLeak, __LINE__, test18, "" );
|
||||
|
||||
|
||||
const char test19[] = "struct abc\n"
|
||||
"{\n"
|
||||
" int a;\n"
|
||||
" int b;\n"
|
||||
" int c;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"static void f()\n"
|
||||
"{\n"
|
||||
" struct abc *abc1 = new abc;\n"
|
||||
" p = &abc1->a;\n"
|
||||
"}\n";
|
||||
check( CheckMemoryLeak, __LINE__, test19, "" );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue