From 6a31fe64030d550004e306654803eac27f3eb812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 28 Dec 2009 16:32:34 +0100 Subject: [PATCH] Fixed #1159 (Valgrind gives error in Tokenizer::simplifyWhile0) --- lib/tokenize.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index f0d0e8833..7c9a05e8d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4969,9 +4969,9 @@ void Tokenizer::simplifyWhile0() // remove "while (0) { .. }" if (Token::simpleMatch(tok->tokAt(4), "{")) { - Token::eraseTokens(tok, tok->tokAt(4)->link()); + const Token *end = tok->tokAt(4)->link(); + Token::eraseTokens(tok, end ? end->next() : 0); tok->deleteThis(); // delete "while" - tok->deleteThis(); // delete "}" } if (Token::simpleMatch(tok->previous(), "}"))