diff options
author | Chip Salzenberg <chip@atlantic.net> | 1997-01-28 23:11:16 +1200 |
---|---|---|
committer | Chip Salzenberg <chip@atlantic.net> | 1997-01-29 18:11:00 +1200 |
commit | 2e3febc6b56a2d689b1b3f47d5fcfc7adade7965 (patch) | |
tree | f051fe1d0dea59402bec8c756a06eddee7bd881a /sv.c | |
parent | 1ca7b98ad174fbe71cdc4e5666d8b6784b21f767 (diff) | |
download | perl-2e3febc6b56a2d689b1b3f47d5fcfc7adade7965.tar.gz |
Deref old stash when re-blessing
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -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; |