diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-06-29 16:28:34 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-06-29 16:28:34 +0000 |
commit | c4a7531db1b7667c9d43fd3494f5bbf4901ff149 (patch) | |
tree | 2d8a0018fcc280a703395bcd79906463032573a8 | |
parent | 21ebe9a66415474b705d94b2a796a167715876c5 (diff) | |
download | perl-c4a7531db1b7667c9d43fd3494f5bbf4901ff149.tar.gz |
Removes the code that is supposed to restore magic on leaving the
localization of an array or a hash. This fixes some memory leaks.
Basically we were overwriting the magic of the outer value (value
from the outer scope) by the magic of the inner value (therefore making
that outer magic leaking in memory). But that inner magic was created
by mg_localize() by copying *some* of the outer magic. Consequently the
outer value already has that magic. So just keep it and don't bother.
That change might introduce obscure bugs. On the other hand, it might
also cure obscure bugs, related to the inner value acquiring container
magic during its lifetime, or to the outer value loosing non-container
magic. No test in the test suite seems to test that.
p4raw-id: //depot/perl@31505
-rw-r--r-- | scope.c | 17 |
1 files changed, 2 insertions, 15 deletions
@@ -680,15 +680,7 @@ Perl_leave_scope(pTHX_ I32 base) av = (AV*)SSPOPPTR; gv = (GV*)SSPOPPTR; if (GvAV(gv)) { - AV * const goner = GvAV(gv); - /* FIXME - this is a temporary hack until we work out what - the correct behaviour for magic should be. */ - sv_unmagic((SV*)goner, PERL_MAGIC_arylen_p); - SvMAGIC_set(av, SvMAGIC(goner)); - SvFLAGS((SV*)av) |= SvMAGICAL(goner); - SvMAGICAL_off(goner); - SvMAGIC_set(goner, NULL); - SvREFCNT_dec(goner); + SvREFCNT_dec(GvAV(gv)); } GvAV(gv) = av; if (SvMAGICAL(av)) { @@ -701,12 +693,7 @@ Perl_leave_scope(pTHX_ I32 base) hv = (HV*)SSPOPPTR; gv = (GV*)SSPOPPTR; if (GvHV(gv)) { - HV * const goner = GvHV(gv); - SvMAGIC_set(hv, SvMAGIC(goner)); - SvFLAGS(hv) |= SvMAGICAL(goner); - SvMAGICAL_off(goner); - SvMAGIC_set(goner, NULL); - SvREFCNT_dec(goner); + SvREFCNT_dec(GvHV(gv)); } GvHV(gv) = hv; if (SvMAGICAL(hv)) { |