[patch] ignore PL_curpm in PL_regex_padav cleanup
Doug MacEachern [Fri, 3 Aug 2001 17:37:53 +0000 (10:37 -0700)]
Message-ID: <Pine.LNX.4.21.0108031730040.23972-100000@mako.covalent.net>

p4raw-id: //depot/perl@11567

perl.c
regexec.c

diff --git a/perl.c b/perl.c
index 7362316..b3d1e31 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -477,8 +477,16 @@ perl_destruct(pTHXx)
         SV **ary = AvARRAY(PL_regex_padav);
 
         while (i) {
-            REGEXP *re = (REGEXP *)SvIVX(ary[--i]);
-            if (re && (re->refcnt > 0)) {
+            SV *resv = ary[--i];
+            REGEXP *re = (REGEXP *)SvIVX(resv);
+
+            if (SvFLAGS(resv) & SVf_BREAK) {
+                /* this is PL_curpm, already freed
+                 * flag is set in regexec.c:S_regtry
+                 */
+                SvFLAGS(resv) &= ~SVf_BREAK;
+            }
+            else {
                 ReREFCNT_dec(re);
             }
         }
index 31a1c6a..ceed381 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -1855,6 +1855,8 @@ S_regtry(pTHX_ regexp *prog, char *startpos)
 #ifdef USE_ITHREADS
             {
                 SV* repointer = newSViv(0);
+                /* so we know which PL_regex_padav element is PL_curpm */
+                SvFLAGS(repointer) |= SVf_BREAK;
                 av_push(PL_regex_padav,repointer);
                 PL_reg_curpm->op_pmoffset = av_len(PL_regex_padav);
                 PL_regex_pad = AvARRAY(PL_regex_padav);