This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PATCH: [perl #133880] assertion failure
authorKarl Williamson <khw@cpan.org>
Thu, 21 Mar 2019 15:35:49 +0000 (09:35 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 21 Mar 2019 16:50:01 +0000 (10:50 -0600)
This was caused by attempting to continue parsing after an error is
found, and later assuming that what came before was valid.  The fix is
to put in something valid that's usable until the parse eventually dies
from what caused this, or some other error.

t/op/tr.t
toke.c

index 0f74936..47d603d 100644 (file)
--- a/t/op/tr.t
+++ b/t/op/tr.t
@@ -13,7 +13,7 @@ BEGIN {
 
 use utf8;
 
-plan tests => 300;
+plan tests => 301;
 
 # Test this first before we extend the stack with other operations.
 # This caused an asan failure due to a bad write past the end of the stack.
@@ -1137,6 +1137,12 @@ for ("", nullrocow) {
     [\x{E5CD}-\x{E5DF}\x{EA80}-\x{EAFA}\x{EB0E}-\x{EB8E}\x{EAFB}-\x{EB0D}\x{E5B5}-\x{E5CC}];
 
     is $x, "\x{E5CE}", '[perl #130656]';
+
+}
+
+{
+    fresh_perl_like('y/\x{a00}0-\N{}//', qr/Unknown charname/, { },
+                    'RT #133880 illegal \N{}');
 }
 
 1;
diff --git a/toke.c b/toke.c
index 755740d..9bed338 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -3783,8 +3783,12 @@ S_scan_const(pTHX_ char *start)
                    }
                }
                else /* Here is \N{NAME} but not \N{U+...}. */
-                     if ((res = get_and_check_backslash_N_name_wrapper(s, e)))
-                {
+                     if (! (res = get_and_check_backslash_N_name_wrapper(s, e)))
+                {   /* Failed.  We should die eventually, but for now use a NUL
+                       to keep parsing */
+                    *d++ = '\0';
+                }
+                else {  /* Successfully evaluated the name */
                     STRLEN len;
                     const char *str = SvPV_const(res, len);
                     if (PL_lex_inpat) {