From fc59284ee7562e1f7891c66f7961cf2e55a064c1 Mon Sep 17 00:00:00 2001 From: Daniel Sipka Date: Fri, 2 Oct 2015 13:08:46 +0200 Subject: [PATCH] invalid iterator bug fix --- src/template_type.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/template_type.cpp b/src/template_type.cpp index b3da2c5..2cc1154 100644 --- a/src/template_type.cpp +++ b/src/template_type.cpp @@ -76,9 +76,10 @@ void template_type::strip_whitespace() { if (has_tag && !non_space) { store_prefixes(line_begin); - for (auto cur = line_begin; it != cur - 1; - cur = (*cur).ws_only() ? tokens.erase(cur) : cur + 1) - it = (*cur).eol() ? cur - 1 : it; + auto c = line_begin; + for (bool end = false; !end; c = (*c).ws_only() ? tokens.erase(c) : ++c) + if ((end = (*c).eol())) + it = c - 1; } non_space = has_tag = false;