This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PATCH: [perl #132163] regex assertion failure
authorKarl Williamson <khw@cpan.org>
Tue, 6 Mar 2018 19:32:58 +0000 (12:32 -0700)
committerKarl Williamson <khw@cpan.org>
Tue, 6 Mar 2018 21:37:46 +0000 (14:37 -0700)
commitfb7e725522eb400ba57f680cea29799ad5c8e4ac
treee7834a0080d74cd24da268e4921731e424598295
parente1168c111a3dbbf8383f433d611b13168096d280
PATCH: [perl #132163] regex assertion failure

The original test case in this ticket has already been fixed; but
modifying it slightly showed some other issues that are now fixed by
this commit.

The deepest problem is that this code in some paths creates a string to
parse instead of the original pattern.  And in some cases, it's not even
the original pattern, but something that had already been created to
parse instead of the pattern.  Any messages that are raised should be
output in terms of the original.  regcomp.c already has the
infrastructure to handle the case where a message is raised during
parsing of a constructed string, but it can't handle a 2nd level
constructed string.  That was what led to the segfault in the original
ticket.  Unrelated fixes caused the original ticket to no longer be
applicable, and so this fix adds tests for things still would cause a
problem.

The method chosen here is to just make sure that the string constructed
here to parse is error free, so no messages will be raised.  Instead it
does the error checking as it constructs the string, so if what is being
parsed to construct a new string is an already constructed one, the
existing infrastructure handles outputting the message relative to the
original pattern.  Since what is being parsed is a series of hex
numbers, it's easy to find out what their values are: just accumulate a
total, shifting 4 bits each time through the loop.  A side benefit is
that this fixes some unreported bugs dealing with an input code point
that overflows.  Prior to this patch, it would error ungracefully.
MANIFEST
pod/perldiag.pod
regcomp.c
t/lib/croak/regcomp [new file with mode: 0644]
utf8.c