From 225114df1c126fd7037b718dc2e71d7efe0051ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 24 Aug 2010 20:50:04 +0200 Subject: [PATCH] Fixed #1960 (cppcheck hangs with 100% cpu load) --- lib/checkmemoryleak.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 658072e47..11f3820cc 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -2230,16 +2230,18 @@ void CheckMemoryLeakInFunction::checkReallocUsage() const Token *tok = _tokenizer->tokens(); while (NULL != (tok = Token::findmatch(tok, ") const| {"))) { - const Token *startOfFunction = tok; - // Record the varid's of the function parameters std::set 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) - parameterVarIds.insert(tok->varId()); + if (tok2->varId() != 0) + 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 unsigned int indentlevel = 0; for (tok = tok->next(); tok; tok = tok->next())