From ea405d95c6cf9b56e52d43192b4b1bdbe1d10f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 28 Nov 2010 07:35:42 +0100 Subject: [PATCH] Fixed #2241 (Segfault checking a file) --- lib/tokenize.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index f07a48b1d..d3ca2691e 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1984,12 +1984,16 @@ bool Tokenizer::tokenize(std::istream &code, while (tok->str() != "{") tok = tok->next(); tok = tok->link(); + if (!tok) + break; } // skip executing scopes (ticket #1984).. if (Token::simpleMatch(tok, "; {")) { tok = tok->next()->link(); + if (!tok) + break; } // skip executing scopes (ticket #1985).. @@ -2002,6 +2006,8 @@ bool Tokenizer::tokenize(std::istream &code, if (Token::simpleMatch(tok, ") {")) tok = tok->next()->link(); } + if (!tok) + break; } // not start of statement? @@ -8650,7 +8656,11 @@ void Tokenizer::simplifyBorland() for (Token *tok = _tokens; tok; tok = tok->next()) { if (tok->str() == "{") + { tok = tok->link(); + if (!tok) + break; + } if (Token::Match(tok, "class %var% :|{")) {