bool dowarn = ckWARN_d(WARN_UTF8);
STRLEN expectlen = 0;
+ if (curlen == 0) {
+ if (dowarn)
+ Perl_warner(aTHX_ WARN_UTF8,
+ "Malformed UTF-8 character (an empty string)");
+ goto malformed;
+ }
+
if (uv <= 0x7f) { /* Pure ASCII. */
if (retlen)
*retlen = 1;
goto malformed;
}
- if ((uv >= 0xc0 && uv <= 0xfd && curlen >1 && s[1] < 0x80) &&
+ if ((uv >= 0xc0 && uv <= 0xfd && curlen > 1 && s[1] < 0x80) &&
!(flags & UTF8_ALLOW_NON_CONTINUATION)) {
if (dowarn)
Perl_warner(aTHX_ WARN_UTF8,
if (dowarn)
Perl_warner(aTHX_ WARN_UTF8,
"Malformed UTF-8 character (%d byte%s, need %d)",
- curlen, curlen > 1 ? "s" : "", expectlen);
+ curlen, curlen == 1 ? "" : "s", expectlen);
goto malformed;
}
if (dowarn)
Perl_warner(aTHX_ WARN_UTF8,
"Malformed UTF-8 character (%d byte%s, need %d)",
- expectlen, expectlen > 1 ? "s": "", UNISKIP(uv));
+ expectlen, expectlen == 1 ? "": "s", UNISKIP(uv));
goto malformed;
}