[perl #32041] SEGV with complicated regexp and long string
Dave Mitchell [Sat, 20 May 2006 00:43:42 +0000 (00:43 +0000)]
PL_reg_maxiter was wrapping to a negative value

p4raw-id: //depot/perl@28248

regexec.c

index f765024..0f5d6fb 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -3652,6 +3652,9 @@ S_regmatch(pTHX_ const regmatch_info *reginfo, regnode *prog)
                        *that* much linear. */
                if (!PL_reg_maxiter) {
                    PL_reg_maxiter = (PL_regeol - PL_bostr + 1) * (scan->flags>>4);
+                   /* possible overflow for long strings and many CURLYX's */
+                   if (PL_reg_maxiter < 0)
+                       PL_reg_maxiter = I32_MAX;
                    PL_reg_leftiter = PL_reg_maxiter;
                }
                if (PL_reg_leftiter-- == 0) {