In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/2abb04977db87a1e49b7f84f7caf49109ee47b22?hp=bdb2361834f8e3746bc3cfae583d1fe35729f04d>

- Log -----------------------------------------------------------------
commit 2abb04977db87a1e49b7f84f7caf49109ee47b22
Author: Father Chrysostomos <[email protected]>
Date:   Fri Nov 30 18:01:40 2012 -0800

    Increase $sort::VERSION to 2.02

M       lib/sort.pm

commit a78dbd0611ca42e3e9bedc216e7192abf12764f2
Author: Martin Becker <[email protected]>
Date:   Fri Nov 30 18:07:43 2012 +0100

    fixed typos in sample code in sort.pm documentation

M       lib/sort.pm

commit 5fab01863c4c001d650fed2b66b50d6c6d0c8aec
Author: Father Chrysostomos <[email protected]>
Date:   Fri Nov 30 09:50:35 2012 -0800

    Stop format closure fatal warnings from leaking

M       pad.c
M       t/op/svleak.t

commit af32a010cd62680d8bd608e309c00d2b3eac337b
Author: Father Chrysostomos <[email protected]>
Date:   Fri Nov 30 09:27:27 2012 -0800

    svleak.t: Correct test name
    
    I got slightly confused when I added that.  I had tested both page
    overflow and closure warnings (only the latter leaked), and I got
    them mixed up when I wrote the test name.

M       t/op/svleak.t

commit c2b36a6de0f63707e6ca496d5f88e40d768a6c0e
Author: Father Chrysostomos <[email protected]>
Date:   Thu Nov 29 22:49:09 2012 -0800

    Stop duplicate lex vars from leaking under fatal warnings

M       pad.c
M       t/op/svleak.t

commit 9593456923bf641a10e8faeb51720606580a4fec
Author: Father Chrysostomos <[email protected]>
Date:   Thu Nov 29 13:07:02 2012 -0800

    Stop newCONSTSUB from leaking the constant under fatal warnings

M       op.c
M       t/op/svleak.t
-----------------------------------------------------------------------

Summary of changes:
 lib/sort.pm   |    6 +++---
 op.c          |    5 ++++-
 pad.c         |   11 +++++++++--
 t/op/svleak.t |    6 +++---
 4 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/lib/sort.pm b/lib/sort.pm
index 922f82b..7c8e50d 100644
--- a/lib/sort.pm
+++ b/lib/sort.pm
@@ -1,6 +1,6 @@
 package sort;
 
-our $VERSION = '2.01';
+our $VERSION = '2.02';
 
 # The hints for pp_sort are now stored in $^H{sort}; older versions
 # of perl used the global variable $sort::hints. -- rjh 2005-12-19
@@ -180,14 +180,14 @@ So now this code would be written:
   { use sort qw(defaults _quicksort); # force quicksort
     no sort "stable";      # stability not wanted
     my $current;
-    BEGIN { $current = print sort::current; }
+    BEGIN { $current = sort::current; }
     print "$current\n";
     @a = sort @b;
     # Pragmas go out of scope at the end of the block
   }
   { use sort qw(defaults stable);     # force stability
     my $current;
-    BEGIN { $current = print sort::current; }
+    BEGIN { $current = sort::current; }
     print "$current\n";
     @c = sort @d;
   }
diff --git a/op.c b/op.c
index c95c8ea..18afb4b 100644
--- a/op.c
+++ b/op.c
@@ -7798,13 +7798,16 @@ Perl_newCONSTSUB_flags(pTHX_ HV *stash, const char 
*name, STRLEN len,
        PL_curstash = (HV *)SvREFCNT_inc_simple_NN(stash);
     }
 
+    /* Protect sv against leakage caused by fatal warnings. */
+    if (sv) SAVEFREESV(sv);
+
     /* file becomes the CvFILE. For an XS, it's usually static storage,
        and so doesn't get free()d.  (It's expected to be from the C pre-
        processor __FILE__ directive). But we need a dynamically allocated one,
        and we need it to get freed.  */
     cv = newXS_len_flags(name, len, const_sv_xsub, file ? file : "", "",
                         &sv, XS_DYNAMIC_FILENAME | flags);
-    CvXSUBANY(cv).any_ptr = sv;
+    CvXSUBANY(cv).any_ptr = SvREFCNT_inc_simple(sv);
     CvCONST_on(cv);
 
     LEAVE;
diff --git a/pad.c b/pad.c
index 0818625..dee5c1c 100644
--- a/pad.c
+++ b/pad.c
@@ -627,8 +627,12 @@ Perl_pad_add_name_pvn(pTHX_ const char *namepv, STRLEN 
namelen,
         flags &= ~padadd_UTF8_NAME;
 
     if ((flags & padadd_NO_DUP_CHECK) == 0) {
+       ENTER;
+       SAVEFREESV(namesv); /* in case of fatal warnings */
        /* check for duplicate declaration */
        pad_check_dup(namesv, flags & padadd_OUR, ourstash);
+       SvREFCNT_inc_simple_void_NN(namesv);
+       LEAVE;
     }
 
     offset = pad_alloc_name(namesv, flags & ~padadd_UTF8_NAME, typestash, 
ourstash);
@@ -1964,7 +1968,7 @@ the immediately surrounding code.
 static CV *S_cv_clone(pTHX_ CV *proto, CV *cv, CV *outside);
 
 static void
-S_cv_clone_pad(pTHX_ CV *proto, CV *cv, CV *outside)
+S_cv_clone_pad(pTHX_ CV *proto, CV *cv, CV *outside, bool newcv)
 {
     dVAR;
     I32 ix;
@@ -2014,6 +2018,7 @@ S_cv_clone_pad(pTHX_ CV *proto, CV *cv, CV *outside)
     ENTER;
     SAVESPTR(PL_compcv);
     PL_compcv = cv;
+    if (newcv) SAVEFREESV(cv); /* in case of fatal warnings */
 
     if (CvHASEVAL(cv))
        CvOUTSIDE(cv)   = MUTABLE_CV(SvREFCNT_inc_simple(outside));
@@ -2108,6 +2113,7 @@ S_cv_clone_pad(pTHX_ CV *proto, CV *cv, CV *outside)
                S_cv_clone(aTHX_ (CV *)ppad[ix], (CV *)PL_curpad[ix], cv);
        }
 
+    if (newcv) SvREFCNT_inc_simple_void_NN(cv);
     LEAVE;
 }
 
@@ -2115,6 +2121,7 @@ static CV *
 S_cv_clone(pTHX_ CV *proto, CV *cv, CV *outside)
 {
     dVAR;
+    const bool newcv = !cv;
 
     assert(!CvUNIQUE(proto));
 
@@ -2140,7 +2147,7 @@ S_cv_clone(pTHX_ CV *proto, CV *cv, CV *outside)
     if (SvMAGIC(proto))
        mg_copy((SV *)proto, (SV *)cv, 0, 0);
 
-    if (CvPADLIST(proto)) S_cv_clone_pad(aTHX_ proto, cv, outside);
+    if (CvPADLIST(proto)) S_cv_clone_pad(aTHX_ proto, cv, outside, newcv);
 
     DEBUG_Xv(
        PerlIO_printf(Perl_debug_log, "\nPad CV clone\n");
diff --git a/t/op/svleak.t b/t/op/svleak.t
index a3c14b8..59ff7f8 100644
--- a/t/op/svleak.t
+++ b/t/op/svleak.t
@@ -91,14 +91,14 @@ eleak(2, 0, "$all *x=sub {}",
      'fatal sub redef warning with sub-to-glob assignment');
 eleak(2, 0, "$all *x=sub() {1}",
      'fatal const sub redef warning with sub-to-glob assignment');
-$::TODO = 'still leaks';
 eleak(2, 0, "$all XS::APItest::newCONSTSUB(\\%main::=>name=>0=>1)",
-     'newXS sub redefinition with fatal warnings');
+     'newCONSTSUB sub redefinition with fatal warnings');
 eleak(2, 0, "$f 'misc'; my\$a,my\$a", 'double my with fatal warnings');
 eleak(2, 0, "$f 'misc'; our\$a,our\$a", 'double our with fatal warnings');
 eleak(2, 0, "$f 'closure';
              sub foo { my \$x; format=\n\@\n\$x\n.\n} write; ",
-     'write beyond end of page with fatal warnings');
+     'format closing over unavailable var with fatal warnings');
+$::TODO = 'still leaks';
 eleak(2, 0, "$all /(?{})?/ ", '(?{})? with fatal warnings');
 eleak(2, 0, "$all /(?{})+/ ", '(?{})+ with fatal warnings');
 eleak(2, 0, "$all /[\\i]/ ", 'invalid charclass escape with fatal warns');

--
Perl5 Master Repository

Reply via email to