Fixed #1936 (Internal error. Token::Match called with varid 0.)

This commit is contained in:
Daniel Marjamäki 2010-08-24 20:58:22 +02:00
parent 225114df1c
commit ca407110dc
2 changed files with 12 additions and 1 deletions

View File

@ -2255,7 +2255,8 @@ void CheckMemoryLeakInFunction::checkReallocUsage()
--indentlevel;
}
if (Token::Match(tok, "%var% = realloc|g_try_realloc ( %var% ,") &&
if (tok->varId() > 0 &&
Token::Match(tok, "%var% = realloc|g_try_realloc ( %var% ,") &&
tok->varId() == tok->tokAt(4)->varId() &&
parameterVarIds.find(tok->varId()) == parameterVarIds.end())
{

View File

@ -333,6 +333,7 @@ private:
TEST_CASE(realloc6);
TEST_CASE(realloc7);
TEST_CASE(realloc8);
TEST_CASE(realloc9);
TEST_CASE(assign);
@ -2059,6 +2060,15 @@ private:
ASSERT_EQUALS("", errout.str());
}
void realloc9()
{
check("void foo()\n"
"{\n"
" x = realloc(x,100);\n"
"}\n", false);
ASSERT_EQUALS("", errout.str());
}
void assign()
{
check("void foo()\n"