Skip to content

Commit

Permalink
PATCH: [perl #37836] Simple Regex causes SEGV
Browse files Browse the repository at this point in the history
As mentioned in the notes in the ticket, the test for this was wrong,
relying on an optimization in the regex compiler that avoided the
problematic code altogether.

When corrected, the test would not segfault, but does croak.  This is
because the regex engine croaks on malformed UTF-8, which this is.
croaking is probably the best option here, and has been in place for a
number of releases.  To fix the test, the pattern is modified by adding
a character to circumvent the optimization, and the croak is guarded by
a fresh_perl
  • Loading branch information
khwilliamson committed Dec 11, 2016
1 parent 05fa1f0 commit 7602410
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions t/re/pat_rt_report.t
Expand Up @@ -510,11 +510,13 @@ sub run_tests {
SKIP:
{
skip "In EBCDIC and unclear what would trigger this bug there" if $::IS_EBCDIC;
no warnings 'utf8';
$_ = pack 'U0C2', 0xa2, 0xf8; # Ill-formed UTF-8
my $ret = 0;
is(do {!($ret = s/[\0]+//g)}, 1,
"Ill-formed UTF-8 doesn't match NUL in class; Bug 37836");
fresh_perl_like(
'no warnings "utf8";
$_ = pack "U0C2", 0xa2, 0xf8; # Ill-formed UTF-8
my $ret = 0;
do {!($ret = s/[a\0]+//g)}',
qr/Malformed UTF-8/,
{}, "Ill-formed UTF-8 doesn't match NUL in class; Bug 37836");
}

{
Expand Down

0 comments on commit 7602410

Please sign in to comment.