difforig perl-5.10.0/perl.c perl-5.10.0/regexec.c

2008-02-08  Reini Urban <rurban@x-ray.at>

diff -ub perl-5.10.0/regexec.c.orig perl-5.10.0/regexec.c
--- perl-5.10.0/regexec.c.orig	2007-12-18 10:47:08.000000000 +0000
+++ perl-5.10.0/regexec.c	2008-02-08 17:11:34.103392000 +0000
@@ -2253,14 +2253,18 @@
 #ifdef USE_ITHREADS
             {
 		SV* const repointer = newSViv(0);
-                /* so we know which PL_regex_padav element is PL_reg_curpm */
-                SvFLAGS(repointer) |= SVf_BREAK;
+                /* this regexp is also owned by the new PL_reg_curpm, which
+		   will try to free it.  */
                 av_push(PL_regex_padav,repointer);
                 PL_reg_curpm->op_pmoffset = av_len(PL_regex_padav);
                 PL_regex_pad = AvARRAY(PL_regex_padav);
             }
 #endif      
         }
+	/* This is safe against NULLs: */
+	ReREFCNT_dec(PM_GETRE(PL_reg_curpm));
+	/* PM_reg_curpm owns a reference to this regexp.  */
+	ReREFCNT_inc(prog);
 	PM_SETRE(PL_reg_curpm, prog);
 	PL_reg_oldcurpm = PL_curpm;
 	PL_curpm = PL_reg_curpm;

