summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utf8.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/utf8.c b/utf8.c
index 2afcbeb787..6c9cebd338 100644
--- a/utf8.c
+++ b/utf8.c
@@ -1323,7 +1323,11 @@ Perl_to_utf8_case(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, char *norma
for (t = ustrp, tend = t + *lenp; t < tend; t += tlen) {
UV c = utf8_to_uvchr(t, &tlen);
- d = uvchr_to_utf8(d, UNI_TO_NATIVE(c));
+
+ if (tlen > 0)
+ d = uvchr_to_utf8(d, UNI_TO_NATIVE(c));
+ else
+ break;
}
*lenp = d - tmpbuf;
Copy(tmpbuf, ustrp, *lenp, U8);