This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PATCH: [perl #12406] regnode panic
authorKarl Williamson <khw@cpan.org>
Tue, 20 Oct 2015 04:51:53 +0000 (22:51 -0600)
committerKarl Williamson <khw@cpan.org>
Tue, 20 Oct 2015 05:02:17 +0000 (23:02 -0600)
This was due to an "=" that should have been a "+=", which ended up in
this situation not allocating enough space for the pattern.  This is not
likely to cause real field problems since the generated pattern won't
succeed, and the problem is warned about and would be corrected.

regcomp.c
t/re/pat.t

index 986d1da..540f71c 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -10940,7 +10940,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
                      * enough space for all the things we are about to throw
                      * away, but we can shrink it by the ammount we are about
                      * to re-use here */
-                    RExC_size = PREVOPER(RExC_size) - regarglen[(U8)OPFAIL];
+                    RExC_size += PREVOPER(RExC_size) - regarglen[(U8)OPFAIL];
                 }
                 else {
                     ckWARNreg(RExC_parse, "Quantifier {n,m} with n > m can't match");
index c6e9209..fb4caf6 100644 (file)
@@ -23,7 +23,7 @@ BEGIN {
     skip_all_without_unicode_tables();
 }
 
-plan tests => 775;  # Update this when adding/deleting tests.
+plan tests => 776;  # Update this when adding/deleting tests.
 
 run_tests() unless caller;
 
@@ -1711,6 +1711,16 @@ EOP
                like($error, qr{Reference to nonexistent group},
                                'gave appropriate error for qr{()(?1)}n');
        }
+
+       {
+            # [perl #126406] panic with unmatchable quantifier
+            my $code='
+                no warnings "regexp";
+                "" =~ m/(.0\N{6,0}0\N{6,0}000000000000000000000000000000000)/;
+            ';
+            fresh_perl_is($code, "", {},
+                            "perl [#126406] panic");
+       }
 } # End of sub run_tests
 
 1;