Memory leak: Better handling of 'if (0 != p)'

This commit is contained in:
Daniel Marjamäki 2008-11-17 17:02:06 +00:00
parent 2dd4dba90e
commit 7e8b3c86f6
2 changed files with 14 additions and 13 deletions

View File

@ -357,7 +357,8 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *>
// if else switch
if ( Match(tok, "if ( %var1% )", varnames) ||
Match(tok, "if ( %var1% != 0 )", varnames) )
Match(tok, "if ( %var1% != 0 )", varnames) ||
Match(tok, "if ( 0 != %var1% )", varnames) )
{
addtoken("if(var)");
tok = Tokenizer::gettok(tok, 3); // Make sure the "use" will not be added

View File

@ -411,18 +411,18 @@ private:
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}
void if3()
{
check( "void f()\n"
"{\n"
" char *s = new char[100];\n"
" if (s != NULL)\n"
" foo(s);\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}
void if3()
{
check( "void f()\n"
"{\n"
" char *s = new char[100];\n"
" if (0 != s)\n"
" foo(s);\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}