Memory leak: Removed false positives. 'use ; use ;' is not always the same as 'use ;'

This commit is contained in:
Daniel Marjamäki 2008-11-09 10:09:42 +00:00
parent c2ea705fd7
commit 26bfab1c7e
2 changed files with 41 additions and 27 deletions

View File

@ -596,7 +596,7 @@ static void CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const char varname[]
}
// Delete second use in "use ; use ;"
while (Match(tok2, "use ; use ;"))
while (Match(tok2, "[;{}] use ; use ;"))
{
erase(tok2, Tokenizer::gettok(tok2,3));
done = false;

View File

@ -66,6 +66,7 @@ private:
TEST_CASE( simple8 );
TEST_CASE( use1 );
TEST_CASE( use2 );
TEST_CASE( ifelse1 );
TEST_CASE( ifelse2 );
@ -207,6 +208,19 @@ private:
}
void use2()
{
check( "void foo()\n"
"{\n"
" char *str = strdup(\"abc\");\n"
" if ( abc ) { memset(str, 0, 3); }\n"
" *somestr = str;\n"
"}\n" );
ASSERT_EQUALS( std::string(""), errout.str() );
}