From 191a913ff9d2bf038a481dcf0285846a6dc0804d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 20 Dec 2009 12:45:34 +0100 Subject: [PATCH] Fixed #1117 (segmentation fault of cppcheck) --- lib/tokenize.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 3165b036e..ddbffee90 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -998,15 +998,21 @@ void Tokenizer::simplifyTemplates() // New type.. std::vector types2; s = ""; - for (const Token *tok3 = tok2->tokAt(2); tok3->str() != ">"; tok3 = tok3->next()) + for (const Token *tok3 = tok2->tokAt(2); tok3 && tok3->str() != ">"; tok3 = tok3->next()) { + if (!tok3->next()) + { + s.clear(); + break; + } + if (tok3->str() != ",") types2.push_back(tok3->str()); s += tok3->str(); } const std::string type2(s); - if (type.size() != types2.size()) + if (type2.empty() || type.size() != types2.size()) { #ifndef NDEBUG std::list locationList; @@ -1022,7 +1028,8 @@ void Tokenizer::simplifyTemplates() _errorLogger->reportErr(errmsg); #endif - + if (type2.empty()) + continue; break; }