summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/utf8.c b/utf8.c
index 6ae92bd0d9..d97a8b003d 100644
--- a/utf8.c
+++ b/utf8.c
@@ -299,7 +299,8 @@ Perl_utf8_to_bytes(pTHX_ U8* s, STRLEN *len)
/* ensure valid UTF8 and chars < 256 before updating string */
while (s < send) {
U8 c = *s++;
- if ( (s >= send) || (*s & 0x80 && c > 0xc3)) {
+ if (c >= 0x80 &&
+ ( (s >= send) || ((*s++ & 0xc0) != 0x80) || ((c & 0xfe) != 0xc2))) {
*len = -1;
return 0;
}