This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Retract #10874 (the hack should be unnecessary by now)
[perl5.git] / perl.c
diff --git a/perl.c b/perl.c
index 7362316..28e8761 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_reg_curpm, already freed
+                 * flag is set in regexec.c:S_regtry
+                 */
+                SvFLAGS(resv) &= ~SVf_BREAK;
+            }
+            else {
                 ReREFCNT_dec(re);
             }
         }