Fixed #1960 (cppcheck hangs with 100% cpu load)

This commit is contained in:
Daniel Marjamäki 2010-08-24 20:50:04 +02:00
parent ce0f65e761
commit 225114df1c
1 changed files with 7 additions and 5 deletions

View File

@ -2230,16 +2230,18 @@ void CheckMemoryLeakInFunction::checkReallocUsage()
const Token *tok = _tokenizer->tokens(); const Token *tok = _tokenizer->tokens();
while (NULL != (tok = Token::findmatch(tok, ") const| {"))) while (NULL != (tok = Token::findmatch(tok, ") const| {")))
{ {
const Token *startOfFunction = tok;
// Record the varid's of the function parameters // Record the varid's of the function parameters
std::set<unsigned int> parameterVarIds; std::set<unsigned int> parameterVarIds;
for (tok = tok->link(); tok && tok->str() != "{"; tok = tok->next()) for (const Token *tok2 = tok->link(); tok2 && tok2->str() != ")"; tok2 = tok2->next())
{ {
if (tok->varId() != 0) if (tok2->varId() != 0)
parameterVarIds.insert(tok->varId()); parameterVarIds.insert(tok2->varId());
} }
while (tok->str() != "{")
tok = tok->next();
const Token *startOfFunction = tok;
// Search for the "var = realloc(var, 100);" pattern within this function // Search for the "var = realloc(var, 100);" pattern within this function
unsigned int indentlevel = 0; unsigned int indentlevel = 0;
for (tok = tok->next(); tok; tok = tok->next()) for (tok = tok->next(); tok; tok = tok->next())