diff --git a/glib/gstring.c b/glib/gstring.c index ad2ec1771..e3ec98b0b 100644 --- a/glib/gstring.c +++ b/glib/gstring.c @@ -995,6 +995,15 @@ g_string_replace (GString *string, g_string_insert (string, pos, replace); cur = string->str + pos + r_len; n++; + /* Only match the empty string once at any given position, to + * avoid infinite loops */ + if (f_len == 0) + { + if (cur[0] == '\0') + break; + else + cur++; + } if (n == limit) break; }