Merge branch 'tf/imap-send-create'
[gitweb.git] / utf8.c
diff --git a/utf8.c b/utf8.c
index b30790d043aa4b01da00686654dfb615a92e75b6..401a6a509e8b4221a539cec6ad67721fc620d64e 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -382,6 +382,9 @@ void strbuf_utf8_replace(struct strbuf *sb_src, int pos, int width,
                        dst += n;
                }
 
+               if (src >= end)
+                       break;
+
                old = src;
                n = utf8_width((const char**)&src, NULL);
                if (!src)       /* broken utf-8, do nothing */