Memory leaks : Fixed false positive for "p" when there is a line such as "p2 = p + 1;"
This commit is contained in:
parent
8a02641ffd
commit
6ef11f3f49
|
@ -570,7 +570,7 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *>
|
|||
addtoken("throw");
|
||||
|
||||
// Assignment..
|
||||
if ( TOKEN::Match(tok,"[)=] %var1% [;)]", varnames) ||
|
||||
if ( TOKEN::Match(tok,"[)=] %var1% [+;)]", varnames) ||
|
||||
TOKEN::Match(tok, "%var1% +=|-=", varnames) )
|
||||
addtoken("use");
|
||||
|
||||
|
|
|
@ -1229,6 +1229,15 @@ private:
|
|||
|
||||
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||
|
||||
check( "void foo()\n"
|
||||
"{\n"
|
||||
" char *a = (char *)malloc(10);\n"
|
||||
" char *p = a + 1;\n"
|
||||
" free(p);\n"
|
||||
"}\n" );
|
||||
|
||||
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||
|
||||
check( "void foo()\n"
|
||||
"{\n"
|
||||
" char *a = (char *)malloc(10);\n"
|
||||
|
|
Loading…
Reference in New Issue