From: divverent Date: Sat, 25 Sep 2010 08:39:29 +0000 (+0000) Subject: Fix again u8_COM_StringLengthNoColors returning always 0 if end is NULL (strlennocol... X-Git-Tag: xonotic-v0.1.0preview~56^2~125 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a315e532aafafc62929aeed9662cdcb66a454172;p=xonotic%2Fdarkplaces.git 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 --- 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)