summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorChip Salzenberg <chip@atlantic.net>1997-01-28 23:11:16 +1200
committerChip Salzenberg <chip@atlantic.net>1997-01-29 18:11:00 +1200
commit2e3febc6b56a2d689b1b3f47d5fcfc7adade7965 (patch)
treef051fe1d0dea59402bec8c756a06eddee7bd881a /sv.c
parent1ca7b98ad174fbe71cdc4e5666d8b6784b21f767 (diff)
downloadperl-2e3febc6b56a2d689b1b3f47d5fcfc7adade7965.tar.gz
Deref old stash when re-blessing
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sv.c b/sv.c
index 0df2eec020..5adbe8a4b7 100644
--- a/sv.c
+++ b/sv.c
@@ -3865,19 +3865,23 @@ HV* stash;
if (SvFLAGS(ref) & (SVs_OBJECT|SVf_READONLY)) {
if (SvREADONLY(ref))
croak(no_modify);
- if (SvOBJECT(ref) && SvTYPE(ref) != SVt_PVIO)
- --sv_objcount;
+ if (SvOBJECT(ref)) {
+ if (SvTYPE(ref) != SVt_PVIO)
+ --sv_objcount;
+ SvREFCNT_dec(SvSTASH(ref));
+ }
}
SvOBJECT_on(ref);
- ++sv_objcount;
+ if (SvTYPE(ref) != SVt_PVIO)
+ ++sv_objcount;
(void)SvUPGRADE(ref, SVt_PVMG);
SvSTASH(ref) = (HV*)SvREFCNT_inc(stash);
#ifdef OVERLOAD
- SvAMAGIC_off(sv);
- if (Gv_AMG(stash)) {
- SvAMAGIC_on(sv);
- }
+ if (Gv_AMG(stash))
+ SvAMAGIC_on(sv);
+ else
+ SvAMAGIC_off(sv);
#endif /* OVERLOAD */
return sv;