diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-01-08 23:54:33 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-01-08 23:54:33 +0000 |
commit | d460ef459c7692518f607c250b9843bea7e01dd6 (patch) | |
tree | cd24ec8713445a650364342ffc6a12cadb0ba9a4 /gv.c | |
parent | 372b2723c1b440727154f21dc614ca857f429e6c (diff) | |
download | perl-d460ef459c7692518f607c250b9843bea7e01dd6.tar.gz |
Fix "scalars leaked" bugs caused by overload magic
(Highlighted by Ilya's DESTROY optimization.)
p4raw-id: //depot/perlio@8371
Diffstat (limited to 'gv.c')
-rw-r--r-- | gv.c | 26 |
1 files changed, 18 insertions, 8 deletions
@@ -1155,6 +1155,23 @@ register GV *gv; } #endif /* Microport 2.4 hack */ +int +Perl_magic_freeovrld(pTHX_ SV *sv, MAGIC *mg) +{ + AMT *amtp = (AMT*)mg->mg_ptr; + if (amtp && AMT_AMAGIC(amtp)) { + int i; + for (i = 1; i < NofAMmeth; i++) { + CV *cv = amtp->table[i]; + if (cv != Nullcv) { + SvREFCNT_dec((SV *) cv); + amtp->table[i] = Nullcv; + } + } + } + return 0; +} + /* Updates and caches the CV's */ bool @@ -1170,18 +1187,11 @@ Perl_Gv_AMupdate(pTHX_ HV *stash) if (mg && amtp->was_ok_am == PL_amagic_generation && amtp->was_ok_sub == PL_sub_generation) return AMT_OVERLOADED(amtp); - if (amtp && AMT_AMAGIC(amtp)) { /* Have table. */ - int i; - for (i=1; i<NofAMmeth; i++) { - if (amtp->table[i]) { - SvREFCNT_dec(amtp->table[i]); - } - } - } sv_unmagic((SV*)stash, 'c'); DEBUG_o( Perl_deb(aTHX_ "Recalcing overload magic in package %s\n",HvNAME(stash)) ); + Zero(&amt,1,AMT); amt.was_ok_am = PL_amagic_generation; amt.was_ok_sub = PL_sub_generation; amt.fallback = AMGfallNO; |