[Perl/perl5] 59f4cf: regex: fix recent bug with fixed utf8 substr
[email protected] (David Mitchell via perl5-changes) Thu, 30 Jul 2026 07:58:22 -0700
| Newsgroups | perl.perl5.changes |
|---|---|
| Message-ID | <Perl/perl5/push/refs/heads/blead/[email protected]> |
Branch: refs/heads/blead
Home: https://github.com/Perl/perl5
Commit: 59f4cfac05d642d06233ba97f740403b75661588
https://github.com/Perl/perl5/commit/59f4cfac05d642d06233ba97f740403b75661588
Author: David Mitchell <[email protected]>
Date: 2026-07-30 (Thu, 30 Jul 2026)
Changed paths:
M regexec.c
M t/re/pat.t
Log Message:
-----------
regex: fix recent bug with fixed utf8 substr
GH #24614
v5.45.0-199-g63f838213c, while fixing a performance bug in the regex
intuit system, introduced a NULL pointer defef under certain
circumstances. In particular, where:
- the pattern is anchored;
- it has a fixed utf8 substring;
- that substring can't be downgraded to non-utf8;
- that pattern is matched against a non-utf8 string at least twice.
The cause is assuming intuit can use the fixed substring if either the
utf8 or non-utf8 is present, but then using the variant relevant to the
utf8-ness of the string being matched (which may be NULL).
The fix is trivial - retrieve the relevant substr SV first, and only use
it if it's non-NULL.
The pattern has to be matched twice due to the way S_to_byte_substr()
works: it's called the first time to attempt to downgrade the fixed and
floating substrings. Because the fixed substring can't be downgraded, it
returns false and intuit_start() abandons the effort. On second
iteration, the floating non-utf8 substr is now present, which is enough
to make intuit_start() skip calling S_to_byte_substr(). This whole area
of intuit is a bit rough.
To unsubscribe from these emails, change your notification settings at https://github.com/Perl/perl5/settings/notifications