In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/644ac3a877e810ca7c69833b568049c1c2665ce9?hp=1870a3e0c320485d79704f9c2363ebe63d5e83ff>

- Log -----------------------------------------------------------------
commit 644ac3a877e810ca7c69833b568049c1c2665ce9
Author: Father Chrysostomos <spr...@cpan.org>
Date:   Thu Nov 1 21:48:22 2012 -0700

    Don’t leak when pushing on to read-only array
    
    $ ./miniperl -Ilib -w -e 'warn $$; while(1){eval {push @-, ""}}'
    
    Croak first instead of creating a new element to store in the
    array first and letting av_store croak.
-----------------------------------------------------------------------

Summary of changes:
 pp.c          |    1 +
 t/op/svleak.t |    6 +++++-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/pp.c b/pp.c
index d1cac93..a402672 100644
--- a/pp.c
+++ b/pp.c
@@ -5080,6 +5080,7 @@ PP(pp_push)
        SPAGAIN;
     }
     else {
+       if (SvREADONLY(ary) && MARK < SP) Perl_croak_no_modify(aTHX);
        PL_delaymagic = DM_DELAY;
        for (++MARK; MARK <= SP; MARK++) {
            SV *sv;
diff --git a/t/op/svleak.t b/t/op/svleak.t
index a705587..15ffb46 100644
--- a/t/op/svleak.t
+++ b/t/op/svleak.t
@@ -15,7 +15,7 @@ BEGIN {
 
 use Config;
 
-plan tests => 42;
+plan tests => 43;
 
 # run some code N times. If the number of SVs at the end of loop N is
 # greater than (N-1)*delta at the end of loop 1, we've got a leak
@@ -283,6 +283,10 @@ leak(2, 0, sub {
     eval { push @a, $die_on_fetch };
 }, 'pushing exploding scalar does not leak');
 
+leak(2, 0, sub {
+    eval { push @-, '' };
+}, 'pushing onto read-only array does not leak');
+
 
 # Run-time regexp code blocks
 {

--
Perl5 Master Repository

Reply via email to