diff options
author | Eric Brine <ikegami@adaelis.com> | 2009-10-23 19:05:40 -0400 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2009-10-28 09:44:00 +0100 |
commit | 02d85cc37a4acecafdc2f0b45640b03cd1f4ac71 (patch) | |
tree | d34568662ba1734cd08f7bb3aa9ea1cde74ada25 /pp.c | |
parent | 34861f291d6c548304b74dfc30ff27447f1b582f (diff) | |
download | perl-02d85cc37a4acecafdc2f0b45640b03cd1f4ac71.tar.gz |
Avoid adding magic with rvalue $#a
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -321,12 +321,19 @@ PP(pp_av2arylen) { dVAR; dSP; AV * const av = MUTABLE_AV(TOPs); - SV ** const sv = Perl_av_arylen_p(aTHX_ MUTABLE_AV(av)); - if (!*sv) { - *sv = newSV_type(SVt_PVMG); - sv_magic(*sv, MUTABLE_SV(av), PERL_MAGIC_arylen, NULL, 0); + const I32 lvalue = PL_op->op_flags & OPf_MOD || LVRET; + if (lvalue) { + SV ** const sv = Perl_av_arylen_p(aTHX_ MUTABLE_AV(av)); + if (!*sv) { + *sv = newSV_type(SVt_PVMG); + sv_magic(*sv, MUTABLE_SV(av), PERL_MAGIC_arylen, NULL, 0); + } + SETs(*sv); + } else { + SETs(sv_2mortal(newSViv( + AvFILL(MUTABLE_AV(av)) + CopARYBASE_get(PL_curcop) + ))); } - SETs(*sv); RETURN; } |