Fixed #2555 (Cppcheck 1.47 - Crash on WinMerge-Trunk (Win7 x64))

This commit is contained in:
Daniel Marjamäki 2011-02-08 20:18:15 +01:00
parent aeae5a867d
commit 56ae77ba87
2 changed files with 13 additions and 1 deletions

View File

@ -1250,7 +1250,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
if ((tok->str() == "else") || (tok->str() == "switch")) if ((tok->str() == "else") || (tok->str() == "switch"))
{ {
addtoken(&rettail, tok, tok->str()); addtoken(&rettail, tok, tok->str());
if (tok->str() == "switch") if (Token::simpleMatch(tok, "switch ("))
tok = tok->next()->link(); tok = tok->next()->link();
continue; continue;
} }

View File

@ -197,6 +197,7 @@ private:
TEST_CASE(switch2); TEST_CASE(switch2);
TEST_CASE(switch3); TEST_CASE(switch3);
TEST_CASE(switch4); // #2555 - segfault
TEST_CASE(ret5); // Bug 2458436 - return use TEST_CASE(ret5); // Bug 2458436 - return use
TEST_CASE(ret6); TEST_CASE(ret6);
@ -1287,6 +1288,17 @@ private:
ASSERT_EQUALS("[test.cpp:9]: (error) Memory leak: str\n", errout.str()); ASSERT_EQUALS("[test.cpp:9]: (error) Memory leak: str\n", errout.str());
} }
void switch4()
{
check("void f() {\n"
" switch MAKEWORD(1)\n"
" {\n"
" case 0:\n"
" return;\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void ret5() void ret5()
{ {