This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regexec.c: Fix failing CI 32-bit tests
authorKarl Williamson <khw@cpan.org>
Mon, 21 Dec 2020 18:04:02 +0000 (11:04 -0700)
committerKarl Williamson <khw@cpan.org>
Mon, 21 Dec 2020 18:09:35 +0000 (11:09 -0700)
This bug was introduced by bb3825626ed2b1217a2ac184eff66d0d4ed6e070, and
was the result of overflowing a 32 bit space.  The solution is to rework
the expression so that it can't overflow.

regexec.c

index 74f95e7..61a3075 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -10019,7 +10019,9 @@ S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p,
                     if (definitive_len == 1) {
                         const char * orig_scan = scan;
 
-                        this_eol = MIN(this_eol, scan + max - hardcount);
+                        if (this_eol - (scan - hardcount) > max) {
+                            this_eol = scan - hardcount + max;
+                        }
 
                         /* Use different routines depending on whether it's an
                          * exact match or matches with a mask */