This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regexec.c: fix #129903: forbid empty pattern in regex code block
authorYves Orton <demerphq@gmail.com>
Tue, 18 Oct 2016 11:11:49 +0000 (13:11 +0200)
committerYves Orton <demerphq@gmail.com>
Wed, 19 Oct 2016 11:28:52 +0000 (13:28 +0200)
commit794826f458d760d13e8727e0e0a3fd7fe79faabd
tree9fb4abaf73b4d1ec2900a71fcfdfb8f8146852a2
parentacfafe8c681b05c76e0a74ef6663970c491cbf50
regexec.c: fix #129903: forbid empty pattern in regex code block

PL_curpm provides access to the data needed to implement
the regex magic vars like $1 and $&. These vars are defined
to reference the last successfully matched pattern, or when
in regex code blocks (?{ ... }) and (??{ ... }), they
should refer to the currently executing pattern.

Unfortunately this collides with its use to implement the
empty pattern special behavior, which requires /just/
"the last successfully matched pattern" everwhere.

This meant that a pattern match like /(?{ s!!! })/ will
infinitely recurse. Fixing this would be difficult, on
the other hand detecting it is not, so we can convert
the infinite recursion/stack overflow into a normal
exception.
pod/perldiag.pod
pp_ctl.c
pp_hot.c