In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/92b69f6501b4d7351e09c8b1ddd386aa7e1c9cd1?hp=95c0a761e6d0916fd6abd02af5a344be7de9ecdb>

- Log -----------------------------------------------------------------
commit 92b69f6501b4d7351e09c8b1ddd386aa7e1c9cd1
Author: Father Chrysostomos <spr...@cpan.org>
Date:   Sun Sep 11 21:29:56 2016 -0700

    [perl #129164] Crash with splice
    
    This fixes #129166 and #129167 as well.
    
    splice needs to take into account that arrays can hold NULLs and
    return &PL_sv_undef in those cases where it would have returned a
    NULL element.
-----------------------------------------------------------------------

Summary of changes:
 pp.c         |  4 ++++
 t/op/array.t | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/pp.c b/pp.c
index 49b6abe..ea49b01 100644
--- a/pp.c
+++ b/pp.c
@@ -5363,6 +5363,8 @@ PP(pp_splice)
                for (i = length - 1, dst = &AvARRAY(ary)[offset]; i > 0; i--)
                    SvREFCNT_dec(*dst++);       /* free them now */
            }
+           if (!*MARK)
+               *MARK = &PL_sv_undef;
        }
        AvFILLp(ary) += diff;
 
@@ -5459,6 +5461,8 @@ PP(pp_splice)
                while (length-- > 0)
                    SvREFCNT_dec(tmparyval[length]);
            }
+           if (!*MARK)
+               *MARK = &PL_sv_undef;
        }
        else
            *MARK = &PL_sv_undef;
diff --git a/t/op/array.t b/t/op/array.t
index 691d6ce..59ba434 100644
--- a/t/op/array.t
+++ b/t/op/array.t
@@ -558,4 +558,21 @@ is $#foo, 3, 'assigning to arylen aliased in 
foreach(scalar $#arylen)';
 sub { undef *_; shift }->(); # This would crash; no ok() necessary.
 sub { undef *_; pop   }->();
 
+# [perl #129164], [perl #129166], [perl #129167]
+# splice() with null array entries
+# These used to crash.
+$#a = -1; $#a++;
+() = 0-splice @a; # subtract
+$#a = -1; $#a++;
+() =  -splice @a; # negate
+$#a = -1; $#a++;
+() = 0+splice @a; # add
+# And with array expansion, too
+$#a = -1; $#a++;
+() = 0-splice @a, 0, 1, 1, 1;
+$#a = -1; $#a++;
+() =  -splice @a, 0, 1, 1, 1;
+$#a = -1; $#a++;
+() = 0+splice @a, 0, 1, 1, 1;
+
 "We're included by lib/Tie/Array/std.t so we need to return something true";

--
Perl5 Master Repository

Reply via email to