Memory Leak: Fixed false positive

This commit is contained in:
Daniel Marjamäki 2008-10-19 07:23:06 +00:00
parent 0658d65a7b
commit f4319a865f
2 changed files with 17 additions and 2 deletions

View File

@ -454,10 +454,10 @@ static void CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const char varname[]
done = false;
}
// Delete "loop ;"
// Replace "loop ;" with ";"
if ( Match(tok2->next, "loop ;") )
{
erase(tok2, gettok(tok2,3));
erase(tok2, gettok(tok2,2));
done = false;
}

View File

@ -40,6 +40,7 @@ private:
TEST_CASE( simple5 );
TEST_CASE( simple6 );
TEST_CASE( simple7 );
TEST_CASE( simple8 );
TEST_CASE( ifelse1 );
TEST_CASE( ifelse2 );
@ -140,6 +141,20 @@ private:
}
void simple8()
{
check( "char * foo ()\n"
"{\n"
" char *str = strdup(\"abc\");\n"
" if (somecondition)\n"
" for (i = 0; i < 2; i++)\n"
" { }\n"
" return str;\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}