Memory leak: Added a simple test case
This commit is contained in:
parent
d5d2f0671c
commit
8dab130d3e
|
@ -380,7 +380,7 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, const char varname[])
|
||||||
|
|
||||||
// if else switch
|
// if else switch
|
||||||
if ( Match(tok, "if ( %var1% )", varnames) ||
|
if ( Match(tok, "if ( %var1% )", varnames) ||
|
||||||
Match(tok, "if ( %var1% != NULL )", varnames) )
|
Match(tok, "if ( %var1% != 0 )", varnames) )
|
||||||
{
|
{
|
||||||
addtoken("if(var)");
|
addtoken("if(var)");
|
||||||
tok = Tokenizer::gettok(tok, 3); // Make sure the "use" will not be added
|
tok = Tokenizer::gettok(tok, 3); // Make sure the "use" will not be added
|
||||||
|
|
|
@ -86,6 +86,7 @@ private:
|
||||||
|
|
||||||
TEST_CASE( if1 );
|
TEST_CASE( if1 );
|
||||||
TEST_CASE( if2 );
|
TEST_CASE( if2 );
|
||||||
|
TEST_CASE( if3 );
|
||||||
|
|
||||||
TEST_CASE( forwhile1 );
|
TEST_CASE( forwhile1 );
|
||||||
TEST_CASE( forwhile2 );
|
TEST_CASE( forwhile2 );
|
||||||
|
@ -412,6 +413,17 @@ private:
|
||||||
ASSERT_EQUALS( std::string(""), errout.str() );
|
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() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue