utf8_to_uvchr_buf: Fix error checking on early EBCDICs
authorKarl Williamson <khw@cpan.org>
Fri, 27 Sep 2019 17:02:43 +0000 (11:02 -0600)
committerNicolas R <atoomic@cpan.org>
Fri, 11 Oct 2019 20:19:07 +0000 (14:19 -0600)
This code assumed ASCII platforms.  It only gets executed in the face of
malformed UTF-8.

(cherry picked from commit b54c9ed809465200054ed546da72925d185992ca)
Signed-off-by: Nicolas R <atoomic@cpan.org>
dist/Devel-PPPort/parts/inc/utf8

index 8a7271d..0e91c07 100644 (file)
@@ -306,7 +306,12 @@ utf8_to_uvchr_buf(pTHX_ const U8 *s, const U8 *send, STRLEN *retlen)
                 *retlen = D_PPP_MIN(*retlen, curlen);
                 *retlen = D_PPP_MIN(*retlen, UTF8SKIP(s));
                 do {
-                    if (s[i] < 0x80 || s[i] > 0xBF) {
+#      ifdef UTF8_IS_CONTINUATION
+                    if (! UTF8_IS_CONTINUATION(s[i]))
+#      else       /* Versions without the above don't support EBCDIC anyway */
+                    if (s[i] < 0x80 || s[i] > 0xBF)
+#      endif
+                    {
                         *retlen = i;
                         break;
                     }