avoid leaked scalar in BEGIN { threads->new(...) }
Dave Mitchell [Sun, 15 May 2005 00:09:35 +0000 (00:09 +0000)]
p4raw-id: //depot/perl@24469

sv.c

diff --git a/sv.c b/sv.c
index 3d4d5b2..06e23ea 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -12425,6 +12425,12 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
 
     SvREFCNT_dec(param->stashes);
 
+    /* orphaned? eg threads->new inside BEGIN or use */
+    if (PL_compcv && ! SvREFCNT(PL_compcv)) {
+       SvREFCNT_inc(PL_compcv);
+       SAVEFREESV(PL_compcv);
+    }
+
     return my_perl;
 }