Memory leaks : Fixed false positive for "p" when there is a line such as "p2 = p + 1;"

This commit is contained in:
Daniel Marjamäki 2008-12-26 20:12:42 +00:00
parent 8a02641ffd
commit 6ef11f3f49
2 changed files with 10 additions and 1 deletions

View File

@ -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");

View File

@ -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"