From f63011c219b3c954dc0442d28cb84dd46bb679cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 29 Jul 2019 19:05:36 +0200 Subject: [PATCH] Try to fix daca@home crashes --- lib/checkunusedvar.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index 53b6a8106..e9ec060fe 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -1171,15 +1171,19 @@ void CheckUnusedVar::checkFunctionVariableUsage() if (FwdAnalysis::isNullOperand(tok->astOperand2())) continue; - if (tok->astOperand1()->variable() && tok->astOperand1()->variable()->isReference() && tok->astOperand1()->variable()->nameToken() != tok->astOperand1()) + if (!tok->astOperand1()) + continue; + + const Variable *op1Var = tok->astOperand1() ? tok->astOperand1()->variable() : nullptr; + if (op1Var && op1Var->isReference() && op1Var->nameToken() != tok->astOperand1()) // todo: check references continue; - if (tok->astOperand1()->variable() && tok->astOperand1()->variable()->isStatic()) + if (op1Var && op1Var->isStatic()) // todo: check static variables continue; - if (tok->astOperand1()->variable() && tok->astOperand1()->variable()->nameToken()->isAttributeUnused()) + if (op1Var && op1Var->nameToken()->isAttributeUnused()) continue; // Is there a redundant assignment?