From bc68ab7490aa70d547deb24a5d9c8d4df44d71c9 Mon Sep 17 00:00:00 2001 From: Tyge Lovset Date: Tue, 29 Nov 2022 20:31:04 +0100 Subject: Fixed bug in utf8 case convertion. --- src/utf8code.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/utf8code.c b/src/utf8code.c index b1534230..2b6e1739 100644 --- a/src/utf8code.c +++ b/src/utf8code.c @@ -156,9 +156,10 @@ cstr cstr_tocase(csview sv, int k) { cstr out = cstr_null; char *buf = cstr_reserve(&out, sv.size*3/2); uint32_t cp; size_t sz = 0; + const char* end = sv.str + sv.size; utf8_decode_t d = {.state=0}; - while (*sv.str) { + while (sv.str != end) { do { utf8_decode(&d, (uint8_t)*sv.str++); } while (d.state); if (d.codep < 128) buf[sz++] = (char)fn_tocase[k].conv_asc((int)d.codep); -- cgit v1.2.3