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 cf786ab..12fd259 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;