memory leak: Fixed a false positive when all is given

This commit is contained in:
Daniel Marjamäki 2009-02-25 19:20:23 +00:00
parent dac1e91013
commit 35583293ec
2 changed files with 19 additions and 6 deletions

View File

@ -892,12 +892,6 @@ void CheckMemoryLeakClass::simplifycode(Token *tok, bool &all)
// Reducing if..
else if (_settings._showAll)
{
if (Token::Match(tok2->next(), "if assign|dealloc|use ; else"))
{
all = true;
erase(tok2->next(), tok2->tokAt(3));
done = false;
}
if (Token::Match(tok2, "[;{}] if { assign|dealloc|use ; return ; } !!else"))
{
all = true;

View File

@ -85,6 +85,7 @@ private:
TEST_CASE(ifelse7);
TEST_CASE(ifelse8);
TEST_CASE(ifelse9);
TEST_CASE(ifelse10);
TEST_CASE(if1);
TEST_CASE(if2);
@ -513,6 +514,24 @@ private:
}
void ifelse10()
{
check("static char *f()\n"
"{\n"
" char *s = new char[10];\n"
" if ( ghfgf )\n"
" {\n"
" str[0] = s;\n"
" }\n"
" else\n"
" {\n"
" str[0] = s;\n"
" }\n"
"}\n", true);
ASSERT_EQUALS(std::string(""), errout.str());
}
void if1()