Fix off by one when cutting utf8-strings
authorWilfried Goesgens <willi@arangodb.com>
Thu, 19 Nov 2015 21:29:53 +0000 (22:29 +0100)
committerWilfried Goesgens <willi@arangodb.com>
Thu, 19 Nov 2015 21:29:53 +0000 (22:29 +0100)
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;