From cf86d365adff47a4a8d37ed9b30df049880c503d Mon Sep 17 00:00:00 2001 From: Brian Ferguson Date: Tue, 5 Nov 2013 10:41:33 -0700 Subject: [PATCH] Fixed error when a self-referencing closing bracket was omitted from the IfCondition --- Library/IfActions.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Library/IfActions.cpp b/Library/IfActions.cpp index 52aa7ef2..3a864f9b 100644 --- a/Library/IfActions.cpp +++ b/Library/IfActions.cpp @@ -251,10 +251,19 @@ bool IfActions::ReplaceSelf(std::wstring& condition, const WCHAR* section, while ((pos = condition.find(measureName, pos)) != std::wstring::npos) { condition.replace(pos, 1, eBracket.substr(0, 1)); - pos = condition.find(sBracket[1], pos); - condition.replace(pos, 1, eBracket.substr(1, 1)); - ++pos; - replaced = true; + pos = condition.find(sBracket.substr(1, 1), pos); + + if (pos != std::wstring::npos) + { + condition.replace(pos, 1, eBracket.substr(1, 1)); + ++pos; + replaced = true; + } + else + { + replaced = false; // No closing bracket found + break; + } } return replaced;