From 04b239322e541b956a060f1785c1a02d46f34d52 Mon Sep 17 00:00:00 2001 From: Twan van Laarhoven Date: Sun, 27 Sep 2020 01:10:49 +0200 Subject: [PATCH] Fix #90: expand_keyword crashed when string ended with tags because of iterator out of bounds. --- CHANGES.md | 3 +++ src/data/keyword.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 240995c1..c83da674 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,9 @@ Magic Set Editor changelog, for the details see `git log` HEAD: new items added as changes are made ------------------------------------------------------------------------------ +Bug fixes: + * Fixed: crash in expand_keywords when given empty tags (#90) + ------------------------------------------------------------------------------ version 2.1.1, 2020-06-14 ------------------------------------------------------------------------------ diff --git a/src/data/keyword.cpp b/src/data/keyword.cpp index b969e4be..f999afbf 100644 --- a/src/data/keyword.cpp +++ b/src/data/keyword.cpp @@ -542,6 +542,7 @@ String expand_keywords(const String& tagged_str, vector const& mat // No match, so there is at least one character not part of a keyword // and possibly some tags before it that we missed skip_tags_for_keyword(true, true); + if (it == end) break; out += *it; ++it; ++untagged_pos;