Memory leak: Better handling of 'if (0 != p)'
This commit is contained in:
parent
2dd4dba90e
commit
7e8b3c86f6
|
@ -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
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue