Fixed #1665 ('If you see this, there is a bug': Token::Match('%var% ( %varid% [,)]', 0))
This commit is contained in:
parent
a390f3c8f4
commit
5d01047ae4
|
@ -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")
|
||||||
|
|
|
@ -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());
|
||||||
|
|
Loading…
Reference in New Issue