summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2017-06-24 11:47:19 -0600
committerSteve Hay <steve.m.hay@googlemail.com>2017-08-29 08:16:17 +0100
commitbc6122dce46195369b8c1400f3a62240095dac43 (patch)
treeb8f51a7c0f9fec61a96e07cc8aa483af82b3ad86
parent84ebf9b3be4f5913d7b6773e278202ab53601958 (diff)
downloadperl-bc6122dce46195369b8c1400f3a62240095dac43.tar.gz
PATCH: [perl #131646] Assertion fail UTF-8 error msg
Instead of croaking with a proper message, creating the message creates an assertion failure. The cause was that there were two ++ operators on a string, so one should subtract 2 to get to the string start, but only 1 was being subtracted. This is a 5.26 regression, but not terribly consequential, as the program is about to die, but it is a trivial fix that allows the reason the crash is happening to be properly displayed to aid debugging, so I'm adding my vote for it for 5.26.1. (cherry picked from commit 1d5030e143202c1e963e1fc91eb6f3afaa2df83e)
-rw-r--r--t/lib/warnings/utf813
-rw-r--r--utf8.c2
2 files changed, 14 insertions, 1 deletions
diff --git a/t/lib/warnings/utf8 b/t/lib/warnings/utf8
index af04d4c54b..64f08290de 100644
--- a/t/lib/warnings/utf8
+++ b/t/lib/warnings/utf8
@@ -783,3 +783,16 @@ BEGIN{
{};$^H=eval'2**400'}Â
EXPECT
Malformed UTF-8 character: \xc2\x0a (unexpected non-continuation byte 0x0a, immediately after start byte 0xc2; need 2 bytes, got 1) at - line 11.
+########
+# NAME [perl #131646]
+BEGIN{
+ if (ord('A') == 193) {
+ print "SKIPPED\n# ebcdic platforms generates different Malformed UTF-8 warnings.";
+ exit 0;
+ }
+}
+no warnings;
+use warnings 'utf8';
+for(uc 0..t){0~~pack"UXp>",exp}
+EXPECT
+Malformed UTF-8 character: \xc2\x00 (unexpected non-continuation byte 0x00, immediately after start byte 0xc2; need 2 bytes, got 1) in smart match at - line 9.
diff --git a/utf8.c b/utf8.c
index 4949bf6584..a3d5f61b64 100644
--- a/utf8.c
+++ b/utf8.c
@@ -1880,7 +1880,7 @@ Perl_bytes_cmp_utf8(pTHX_ const U8 *b, STRLEN blen, const U8 *u, STRLEN ulen)
/* diag_listed_as: Malformed UTF-8 character%s */
Perl_ck_warner_d(aTHX_ packWARN(WARN_UTF8),
"%s %s%s",
- unexpected_non_continuation_text(u - 1, 2, 1, 2),
+ unexpected_non_continuation_text(u - 2, 2, 1, 2),
PL_op ? " in " : "",
PL_op ? OP_DESC(PL_op) : "");
return -2;