From 5a9328f26a4d63b02dc5b5620dafd09a6f166e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 8 Jul 2015 13:41:27 +0200 Subject: [PATCH] Fixed Cppcheck warning about possible null pointer dereference --- lib/checkother.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 062fadf2b..b6dbf6d28 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -306,12 +306,12 @@ void CheckOther::clarifyStatement() const Scope * scope = symbolDatabase->functionScopes[i]; for (const Token* tok = scope->classStart; tok && tok != scope->classEnd; tok = tok->next()) { if (Token::Match(tok, "* %name%") && tok->astOperand1()) { - const Token *tok2=tok->previous(); + const Token *tok2 = tok->previous(); while (tok2 && tok2->str() == "*") tok2 = tok2->previous(); - if (!tok2->astParent() && Token::Match(tok2, "[{};]")) { + if (tok2 && !tok2->astParent() && Token::Match(tok2, "[{};]")) { tok2 = tok->astOperand1(); if (Token::Match(tok2, "++|-- [;,]")) clarifyStatementError(tok2);