Fix leaks in List::Util::reduce,first
Dave Mitchell [Sat, 26 Feb 2005 00:47:03 +0000 (00:47 +0000)]
When the block is a closure, the cloned CV created on each call
was never freed

p4raw-id: //depot/perl@23996

ext/List/Util/Util.xs
ext/List/Util/lib/Scalar/Util.pm

index 1a996f5..81e35cf 100644 (file)
@@ -250,6 +250,7 @@ CODE:
     }
     ST(0) = ret;
     POPBLOCK(cx,PL_curpm);
+    LEAVESUB(cv);
     CATCH_SET(oldcatch);
     XSRETURN(1);
 }
@@ -290,8 +291,6 @@ CODE:
     CATCH_SET(TRUE);
     PUSHBLOCK(cx, CXt_SUB, SP);
     PUSHSUB(cx);
-    if (!CvDEPTH(cv))
-        (void)SvREFCNT_inc(cv);
 
     for(index = 1 ; index < items ; index++) {
        GvSV(PL_defgv) = ST(index);
@@ -300,11 +299,13 @@ CODE:
        if (SvTRUE(*PL_stack_sp)) {
          ST(0) = ST(index);
          POPBLOCK(cx,PL_curpm);
+         LEAVESUB(cv);
          CATCH_SET(oldcatch);
          XSRETURN(1);
        }
     }
     POPBLOCK(cx,PL_curpm);
+    LEAVESUB(cv);
     CATCH_SET(oldcatch);
     XSRETURN_UNDEF;
 }
index e2bbb5c..089a436 100644 (file)
@@ -11,7 +11,7 @@ require List::Util; # List::Util loads the XS
 
 @ISA       = qw(Exporter);
 @EXPORT_OK = qw(blessed dualvar reftype weaken isweak tainted readonly openhandle refaddr isvstring looks_like_number set_prototype);
-$VERSION    = "1.14";
+$VERSION    = "1.14_1";
 $VERSION   = eval $VERSION;
 
 sub export_fail {