From: Reinhold Kainhofer Date: Fri, 21 Aug 2009 22:04:28 +0000 (+0200) Subject: Fix possible endless loop in replace_all X-Git-Tag: release/2.13.4-1~171 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=8c75c6e62e5e11b54e5585c7a4d1329f9212b1d4;p=lilypond.git Fix possible endless loop in replace_all Inside replace all, start the search for the next appearance from the end position of the replacement, not from the end of the occurrence. Otherwise, replace_all (&str, "\"", "\\\"") will result in an endless loop. --- diff --git a/flower/std-string.cc b/flower/std-string.cc index 285c51883c..53fd548bfa 100644 --- a/flower/std-string.cc +++ b/flower/std-string.cc @@ -80,7 +80,8 @@ string & replace_all (string *str, string const &find, string const &replace) { ssize len = find.length (); - for (ssize i = str->find (find); i != NPOS; i = str->find (find, i + len)) + ssize replen = replace.length (); + for (ssize i = str->find (find); i != NPOS; i = str->find (find, i + replen)) *str = str->replace (i, len, replace); return *str; }