Fix off by one when cutting utf8-strings
[citadel.git] / libcitadel / lib / stringbuf.c
index cf786ab5f10956a3dc94de6265f120fcaf41eac1..12fd259e4582ef93d9da48158582d4a0ca0bca40 100644 (file)
@@ -4142,11 +4142,11 @@ long StrBuf_Utf8StrCut(StrBuf *Buf, int maxlen)
                        n++;
                        aptr++;
                }
-               if (n > maxlen) {
+               if (n >= maxlen) {
                        *aptr = '\0';
                        Buf->BufUsed = aptr - Buf->buf;
                        return Buf->BufUsed;
-               }                       
+               }
        }
        return Buf->BufUsed;