From 9dfb864522404662518449864add9f14ff799fee Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sun, 1 Feb 2015 15:21:09 +0100 Subject: [PATCH] Fixed two nullpointer messages in cppcheck --- lib/library.cpp | 2 +- lib/tokenize.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/library.cpp b/lib/library.cpp index 5460e1c0c..ac29fad9a 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -635,7 +635,7 @@ bool Library::isScopeNoReturn(const Token *end, std::string *unknownFunc) const const Token *funcname = end->linkAt(-2)->previous(); const Token *start = funcname; - if (funcname && Token::Match(funcname->tokAt(-3),"( * %name% )")) { + if (Token::Match(funcname->tokAt(-3),"( * %name% )")) { funcname = funcname->previous(); start = funcname->tokAt(-3); } else if (funcname->isName()) { diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 07a0b2ae8..82160233b 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7567,9 +7567,11 @@ void Tokenizer::simplifyEnum() //jump back once, see the comment at the end of the function goback = false; tok = tok->previous(); + if (!tok) + break; } - if (tok && tok->next() && + if (tok->next() && (!tok->previous() || (tok->previous()->str() != "enum")) && Token::Match(tok, "class|struct|namespace")) { className = tok->next()->str();