From a315e532aafafc62929aeed9662cdcb66a454172 Mon Sep 17 00:00:00 2001 From: divverent Date: Sat, 25 Sep 2010 08:39:29 +0000 Subject: [PATCH] Fix again u8_COM_StringLengthNoColors returning always 0 if end is NULL (strlennocol case), and counting 1 less character if the last character is multibyte and end is not NULL Signed-off-by: terencehill git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10492 d7cf8633-e32d-0410-b094-e92efae38249 --- utf8lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utf8lib.c b/utf8lib.c index 0461672d..268ec7e3 100644 --- a/utf8lib.c +++ b/utf8lib.c @@ -691,7 +691,7 @@ u8_COM_StringLengthNoColors(const char *_s, size_t size_s, qboolean *valid) for(;;) { - switch((s >= end) ? 0 : *s) + switch((s == end) ? 0 : *s) { case 0: if(valid) @@ -756,7 +756,7 @@ u8_COM_StringLengthNoColors(const char *_s, size_t size_s, qboolean *valid) return len; } - if(s + st + ln >= end) + if(end && s + st + ln > end) { // string length exceeded by new character if(valid) -- 2.39.2