From c05a80d314f510e88fd1bb4a10a2d6af5a172bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 28 Sep 2013 16:51:38 +0200 Subject: [PATCH] zero division or useless condition: dont crash when variable declaration is not parsed correctly --- lib/checkother.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 3116ac7e6..c086959ef 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2171,7 +2171,9 @@ void CheckOther::checkZeroDivisionOrUselessCondition() if (!var) continue; bool isVarUnsigned = var->typeEndToken()->isUnsigned(); - for (const Token *typetok = var->typeStartToken(); typetok != var->typeEndToken(); typetok = typetok->next()) { + for (const Token *typetok = var->typeStartToken(); typetok; typetok = typetok->next()) { + if (!typetok->isName() || typetok == var->typeEndToken()) + break; if (typetok->isUnsigned()) { isVarUnsigned = true; break;