This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH: perl@7825] SvTEMP-ness on rhs of aassign can wreak havoc
authorBenjamin Holzman <bah@ecnvantage.com>
Sun, 26 Nov 2000 02:42:34 +0000 (21:42 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Sun, 26 Nov 2000 18:31:12 +0000 (18:31 +0000)
Message-ID: <20001126024234.G25040@ecnvantage.com>

Patch for the bug 20000212.002.

p4raw-id: //depot/perl@7867

sv.c
t/op/array.t

diff --git a/sv.c b/sv.c
index 1720101..be1947a 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -2860,7 +2860,8 @@ Perl_sv_setsv(pTHX_ SV *dstr, register SV *sstr)
        if (SvTEMP(sstr) &&             /* slated for free anyway? */
            SvREFCNT(sstr) == 1 &&      /* and no other references to it? */
            !(sflags & SVf_OOK) &&      /* and not involved in OOK hack? */
-           SvLEN(sstr))                        /* and really is a string */
+           SvLEN(sstr)         &&      /* and really is a string */
+           !(PL_op && PL_op->op_type == OP_AASSIGN)) /* and won't be needed again, potentially */
        {
            if (SvPVX(dstr)) {          /* we know that dtype >= SVt_PV */
                if (SvOOK(dstr)) {
index 7cc84e3..d48b5fb 100755 (executable)
@@ -1,6 +1,6 @@
 #!./perl
 
-print "1..70\n";
+print "1..71\n";
 
 #
 # @foo, @bar, and @ary are also used from tie-stdarray after tie-ing them
@@ -229,3 +229,8 @@ print "ok 69\n";
 
 print "not " unless unshift(@ary,12) == 5;
 print "ok 70\n";
+
+sub foo { "a" }
+@foo=(foo())[0,0];
+$foo[1] eq "a" or print "not ";
+print "ok 71\n";