Memory leak: Added a simple test case

This commit is contained in:
Daniel Marjamäki 2008-11-16 07:33:28 +00:00
parent d5d2f0671c
commit 8dab130d3e
2 changed files with 13 additions and 1 deletions

View File

@ -380,7 +380,7 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, const char varname[])
// if else switch
if ( Match(tok, "if ( %var1% )", varnames) ||
Match(tok, "if ( %var1% != NULL )", varnames) )
Match(tok, "if ( %var1% != 0 )", varnames) )
{
addtoken("if(var)");
tok = Tokenizer::gettok(tok, 3); // Make sure the "use" will not be added

View File

@ -86,6 +86,7 @@ private:
TEST_CASE( if1 );
TEST_CASE( if2 );
TEST_CASE( if3 );
TEST_CASE( forwhile1 );
TEST_CASE( forwhile2 );
@ -412,6 +413,17 @@ private:
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() );
}