summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/utf8code.c3
1 files changed, 2 insertions, 1 deletions
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);