Skip to content

Commit

Permalink
PATCH: [perl #12406] regnode panic
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
khwilliamson committed Oct 20, 2015
1 parent af2f850 commit 9457bb3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion regcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
12 changes: 11 additions & 1 deletion t/re/pat.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

0 comments on commit 9457bb3

Please sign in to comment.