From ddb1f1b5ce4f883daef53fa527413c7fed09063f Mon Sep 17 00:00:00 2001 From: Paul Fultz II Date: Tue, 10 Sep 2019 12:39:44 -0500 Subject: [PATCH] Try to fix issue 9341: daca crash: isContainerSizeChangedByFunction (#2168) --- lib/valueflow.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 7b3a3b92a..7c97af3de 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -5322,17 +5322,19 @@ static bool isContainerSizeChangedByFunction(const Token *tok, int depth = 20) const Function * fun = ftok->function(); if (fun) { const Variable *arg = fun->getArgumentVar(narg); - if (!arg->isReference() && !addressOf) - return false; - if (arg->isConst()) - return false; - const Scope * scope = fun->functionScope; - if (scope) { - // Argument not used - if (!arg->nameToken()) + if (arg) { + if (!arg->isReference() && !addressOf) return false; - if (depth > 0) - return isContainerSizeChanged(arg->declarationId(), scope->bodyStart, scope->bodyEnd, depth - 1); + if (arg->isConst()) + return false; + const Scope * scope = fun->functionScope; + if (scope) { + // Argument not used + if (!arg->nameToken()) + return false; + if (depth > 0) + return isContainerSizeChanged(arg->declarationId(), scope->bodyStart, scope->bodyEnd, depth - 1); + } } }