summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2003-03-20 01:26:19 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-03-26 19:48:32 +0000
commit51d9a56bf5df931c436b7ede535c78bc64655187 (patch)
tree9332cda73b9729a8ee8f37a65886cef9a57d821c /scope.c
parent09e367548f5622c5830617d648540b181c40aa53 (diff)
downloadperl-51d9a56bf5df931c436b7ede535c78bc64655187.tar.gz
[PATCH] Re: [perl #21542] local $_ [0] = $_ [0] fails.
Date: Thu, 20 Mar 2003 01:26:19 +0000 Message-ID: <20030320012619.C19869@fdgroup.com> Subject: Re: [PATCH] Re: [perl #21542] local $_ [0] = $_ [0] fails. From: Dave Mitchell <davem@fdgroup.com> Date: Mon, 24 Mar 2003 16:06:51 +0000 Message-ID: <20030324160651.D1798@fdgroup.com> p4raw-id: //depot/perl@19064
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/scope.c b/scope.c
index a5cc4f49fa..a64ec3e86d 100644
--- a/scope.c
+++ b/scope.c
@@ -604,6 +604,9 @@ Perl_save_aelem(pTHX_ AV *av, I32 idx, SV **sptr)
SSPUSHINT(idx);
SSPUSHPTR(SvREFCNT_inc(*sptr));
SSPUSHINT(SAVEt_AELEM);
+ /* if it gets reified later, the restore will have the wrong refcnt */
+ if (!AvREAL(av) && AvREIFY(av))
+ SvREFCNT_inc(*sptr);
save_scalar_at(sptr);
sv = *sptr;
/* If we're localizing a tied array element, this new sv
@@ -686,7 +689,7 @@ Perl_leave_scope(pTHX_ I32 base)
value = (SV*)SSPOPPTR;
gv = (GV*)SSPOPPTR;
ptr = &GvSV(gv);
- SvREFCNT_dec(gv);
+ av = (AV*)gv; /* what to refcnt_dec */
goto restore_sv;
case SAVEt_GENERIC_PVREF: /* generic pv */
str = (char*)SSPOPPTR;
@@ -719,6 +722,7 @@ Perl_leave_scope(pTHX_ I32 base)
case SAVEt_SVREF: /* scalar reference */
value = (SV*)SSPOPPTR;
ptr = SSPOPPTR;
+ av = Nullav; /* what to refcnt_dec */
restore_sv:
sv = *(SV**)ptr;
DEBUG_S(PerlIO_printf(Perl_debug_log,
@@ -754,6 +758,8 @@ Perl_leave_scope(pTHX_ I32 base)
SvSETMAGIC(value);
PL_localizing = 0;
SvREFCNT_dec(value);
+ if (av) /* actually an av, hv or gv */
+ SvREFCNT_dec(av);
break;
case SAVEt_AV: /* array reference */
av = (AV*)SSPOPPTR;
@@ -963,13 +969,14 @@ Perl_leave_scope(pTHX_ I32 base)
value = (SV*)SSPOPPTR;
i = SSPOPINT;
av = (AV*)SSPOPPTR;
+ if (!AvREAL(av) && AvREIFY(av)) /* undo reify guard */
+ SvREFCNT_dec(value);
ptr = av_fetch(av,i,1);
if (ptr) {
sv = *(SV**)ptr;
if (sv && sv != &PL_sv_undef) {
if (SvTIED_mg((SV*)av, PERL_MAGIC_tied))
(void)SvREFCNT_inc(sv);
- SvREFCNT_dec(av);
goto restore_sv;
}
}
@@ -987,8 +994,8 @@ Perl_leave_scope(pTHX_ I32 base)
ptr = &HeVAL((HE*)ptr);
if (SvTIED_mg((SV*)hv, PERL_MAGIC_tied))
(void)SvREFCNT_inc(*(SV**)ptr);
- SvREFCNT_dec(hv);
SvREFCNT_dec(sv);
+ av = (AV*)hv; /* what to refcnt_dec */
goto restore_sv;
}
}