From: Wilfried Goesgens Date: Thu, 19 Nov 2015 21:29:53 +0000 (+0100) Subject: Fix off by one when cutting utf8-strings X-Git-Tag: Release_902~130 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=5b729848bea9433b5473a31cbf3b53aa373fa0a2 Fix off by one when cutting utf8-strings --- diff --git a/libcitadel/lib/stringbuf.c b/libcitadel/lib/stringbuf.c index cf786ab5f..12fd259e4 100644 --- a/libcitadel/lib/stringbuf.c +++ b/libcitadel/lib/stringbuf.c @@ -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;