Symboldatabase: Fix possible null pointer dereference if smart pointer type does not have a scope

This commit is contained in:
Daniel Marjamäki 2019-07-08 17:43:45 +02:00
parent 9b674fa306
commit 862c4ef87b
1 changed files with 2 additions and 2 deletions

View File

@ -4455,10 +4455,10 @@ const Function* SymbolDatabase::findFunction(const Token *tok) const
const Token *tok1 = tok->tokAt(-2);
if (Token::Match(tok1, "%var% .")) {
const Variable *var = getVariableFromVarId(tok1->varId());
if (var && var->smartPointerType() && tok1->next()->originalName() == "->")
return var->smartPointerType()->classScope->findFunction(tok, var->valueType()->constness == 1);
if (var && var->typeScope())
return var->typeScope()->findFunction(tok, var->valueType()->constness == 1);
if (var && var->smartPointerType() && var->smartPointerType()->classScope && tok1->next()->originalName() == "->")
return var->smartPointerType()->classScope->findFunction(tok, var->valueType()->constness == 1);
} else if (Token::simpleMatch(tok->previous()->astOperand1(), "(")) {
const Token *castTok = tok->previous()->astOperand1();
if (castTok->isCast()) {