Fixed #1665 ('If you see this, there is a bug': Token::Match('%var% ( %varid% [,)]', 0))

This commit is contained in:
Daniel Marjamäki 2010-05-10 18:11:02 +02:00
parent a390f3c8f4
commit 5d01047ae4
2 changed files with 6 additions and 3 deletions

View File

@ -183,7 +183,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getReallocationType(const Token *tok
if (! tok2) if (! tok2)
return No; return No;
if (! Token::Match(tok2, "%var% ( %varid% [,)]", varid)) if (varid > 0 && ! Token::Match(tok2, "%var% ( %varid% [,)]", varid))
return No; return No;
if (tok2->str() == "realloc") if (tok2->str() == "realloc")

View File

@ -1660,7 +1660,10 @@ private:
"static void b()\n" "static void b()\n"
"{\n" "{\n"
" char *p = a(0);\n" " char *p = a(0);\n"
" char *p = a(p);\n" " char *q = a(p);\n"
" if (q)\n"
" free(q);\n"
" else\n"
" free(p);\n" " free(p);\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS(std::string(""), errout.str());