[perl #38906] Regex engine does not release MINMOD
authorAnimator <unknown>
Wed, 12 Apr 2006 15:27:41 +0000 (08:27 -0700)
committerDave Mitchell <davem@fdisolutions.com>
Wed, 12 Apr 2006 23:51:57 +0000 (23:51 +0000)
From: "Animator via RT" <perlbug-followup@perl.org>
Message-ID: <rt-3.0.11-38906-132222.3.24032491323436@perl.org>

zero-length minimum matches that failed could leak into a following
maximal match

p4raw-id: //depot/perl@27782

regexec.c
t/op/re_tests

index 71eab5b..47c4422 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -2211,6 +2211,7 @@ typedef struct {
     regnode *next;
     char *locinput;
     I32 nextchr;
+    int minmod;
 #ifdef DEBUGGING
     int regindent;
 #endif
@@ -3795,6 +3796,7 @@ S_regmatch(pTHX_ regexp *rex, regnode *prog)
                    uw->next = next;
                    uw->locinput = locinput;
                    uw->nextchr = nextchr;
+                   uw->minmod = st->minmod;
 #ifdef DEBUGGING
                    uw->regindent = ++PL_regindent;
 #endif
@@ -4503,6 +4505,7 @@ do_no:
                PL_regendp[n] = -1;
            *PL_reglastparen = n;
            scan = next = uwb->next;
+           st->minmod = uwb->minmod;
            if ( !scan ||
                 OP(scan) != (uwb->type == RE_UNWIND_BRANCH
                              ? BRANCH : BRANCHJ) ) {           /* Failure */
index 8520d99..4b9ae61 100644 (file)
@@ -959,3 +959,5 @@ x(?#        x       c       -       Sequence (?#... not terminated
 ^(a*?)(?!(aa|aaaa)*$)  aaaaaaaaaaaaaaaaaaaa    y       $1      a       # [perl #34195]
 ^(a*?)(?!(aa|aaaa)*$)(?=a\z)   aaaaaaaa        y       $1      aaaaaaa
 ^(.)\s+.$(?(1))        A B     y       $1      A       # [perl #37688]
+(?:r?)*?r|(.{2,4})     abcde   y       $1      abcd
+(?!)+?|(.{2,4})        abcde   y       $1      abcd