Bug hunting: prevent recursion in analysis when code calls self

This commit is contained in:
Daniel Marjamäki 2020-12-13 09:33:40 +01:00
parent be16b2c276
commit 0ccc5c695b
1 changed files with 5 additions and 0 deletions

View File

@ -1952,6 +1952,11 @@ static ExprEngine::ValuePtr executeFunctionCall(const Token *tok, Data &data)
bool hasBody = tok->astOperand1()->function() && tok->astOperand1()->function()->hasBody();
if (hasBody) {
const Scope *functionScope = tok->scope();
while (functionScope->isExecutable() && functionScope->type != Scope::ScopeType::eFunction)
functionScope = functionScope->nestedIn;
if (functionScope == tok->astOperand1()->function()->functionScope)
hasBody = false;
for (const auto &errorPathItem: data.errorPath) {
if (errorPathItem.first == tok) {
hasBody = false;