This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
intuit_more: no need to copy before keyword check
authorHugo van der Sanden <hv@crypt.org>
Fri, 16 Jan 2015 12:11:32 +0000 (12:11 +0000)
committerHugo van der Sanden <hv@crypt.org>
Tue, 20 Jan 2015 13:25:15 +0000 (13:25 +0000)
That also avoids crashing on overrun.

t/re/pat.t
toke.c

index ec68e6b..3d52554 100644 (file)
@@ -22,7 +22,7 @@ BEGIN {
     skip_all_without_unicode_tables();
 }
 
-plan tests => 757;  # Update this when adding/deleting tests.
+plan tests => 759;  # Update this when adding/deleting tests.
 
 run_tests() unless caller;
 
@@ -1626,6 +1626,15 @@ EOP
         like("TffffffffffffT\x{100}TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT5TTTTTTTTTTTTTTTTTTTTTTTTT3TTgTTTTTTTTTTTTTTTTTTTTT2TTTTTTTTTTTTTTTTTTTTTTTHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHiHHHHHHHfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff&ffff", qr/TffffffffffffT\x{100}TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT5TTTTTTTTTTTTTTTTTTTTTTTTT3TTgTTTTTTTTTTTTTTTTTTTTT2TTTTTTTTTTTTTTTTTTTTTTTHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHiHHHHHHHfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff&ffff/il, "");
     }
 
+       {       # [perl #123604]
+               my($s, $x, @x) = ('abc', 'a', 'd');
+               my $long = 'b' x 2000;
+               my $eval = q{$s =~ m{$x[bbb]c} ? 1 : 0};
+               $eval =~ s{bbb}{$long};
+               my $match = eval $eval;
+               ok(1, "did not crash");
+               ok($match, "[bbb...] resolved as character class, not subscript");
+       }
 } # End of sub run_tests
 
 1;
diff --git a/toke.c b/toke.c
index 55d3af9..f34bbee 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -3827,11 +3827,10 @@ S_intuit_more(pTHX_ char *s)
                    && !(last_un_char == '$' || last_un_char == '@'
                         || last_un_char == '&')
                    && isALPHA(*s) && s[1] && isALPHA(s[1])) {
-                   char *d = tmpbuf;
+                   char *d = s;
                    while (isALPHA(*s))
-                       *d++ = *s++;
-                   *d = '\0';
-                   if (keyword(tmpbuf, d - tmpbuf, 0))
+                       s++;
+                   if (keyword(d, s - d, 0))
                        weight -= 150;
                }
                if (un_char == last_un_char + 1)