Merge branch 'master' of git@github.com:danmar/cppcheck

This commit is contained in:
Kimmo Varis 2009-06-05 10:38:28 +03:00
commit 337721f740
2 changed files with 20 additions and 2 deletions

View File

@ -657,10 +657,17 @@ Token *CheckMemoryLeakClass::getcode(const Token *tok, std::list<const Token *>
else if (Token::simpleMatch(tok->next(), "("))
{
int parlevel = 1;
for (const Token *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next())
{
if (tok2->str() == "(" || tok2->str() == ")")
break;
if (tok2->str() == "(")
++parlevel;
else if (tok2->str() == ")")
{
if (parlevel <= 1)
break;
--parlevel;
}
if (tok2->str() == varname)
{

View File

@ -123,6 +123,7 @@ private:
TEST_CASE(ret5); // Bug 2458436 - return use
TEST_CASE(ret6);
TEST_CASE(ret7);
TEST_CASE(ret8);
TEST_CASE(mismatch1);
TEST_CASE(mismatch2);
@ -1094,6 +1095,16 @@ private:
ASSERT_EQUALS("", errout.str());
}
void ret8()
{
check("char *foo()\n"
"{\n"
" char *c = new char[50];\n"
" return ((char *)(c+1));\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void mismatch1()
{