From 65498b5e9a7893439cd6c9a2ff994608b9a6113b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 21 Jun 2020 15:15:43 +0200 Subject: [PATCH] Bug hunting; Fixed hang when there is recursion --- lib/exprengine.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/exprengine.cpp b/lib/exprengine.cpp index 9dd39f8bf..19ab93b57 100644 --- a/lib/exprengine.cpp +++ b/lib/exprengine.cpp @@ -1743,7 +1743,15 @@ static ExprEngine::ValuePtr executeFunctionCall(const Token *tok, Data &data) return retVal; } - const bool hasBody = tok->astOperand1()->function() && tok->astOperand1()->function()->hasBody(); + bool hasBody = tok->astOperand1()->function() && tok->astOperand1()->function()->hasBody(); + if (hasBody) { + for (const auto &errorPathItem: data.errorPath) { + if (errorPathItem.first == tok) { + hasBody = false; + break; + } + } + } const std::vector &argTokens = getArguments(tok); std::vector argValues; @@ -1784,7 +1792,7 @@ static ExprEngine::ValuePtr executeFunctionCall(const Token *tok, Data &data) } // Execute subfunction.. - if (function->hasBody()) { + if (hasBody) { const Scope * const functionScope = function->functionScope; int argnr = 0; std::map refs; @@ -1808,6 +1816,7 @@ static ExprEngine::ValuePtr executeFunctionCall(const Token *tok, Data &data) assignExprValue(ref.first, v, data); } } catch (BugHuntingException &e) { + data.errorPath.pop_back(); e.tok = tok; throw e; // cppcheck-suppress exceptRethrowCopy }