Change 33475 by [EMAIL PROTECTED] on 2008/03/11 17:06:04

        Integrate:
        [ 31505]
        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.
        
        [ 31511]
        test that localised tieing of a hash or array remains local
        (tests for change #31505)

Affected files ...

... //depot/maint-5.8/perl/scope.c#72 integrate
... //depot/maint-5.8/perl/t/op/tie.t#19 integrate

Differences ...

==== //depot/maint-5.8/perl/scope.c#72 (text) ====
Index: perl/scope.c
--- perl/scope.c#71~33214~      2008-02-02 14:01:39.000000000 -0800
+++ perl/scope.c        2008-03-11 10:06:04.000000000 -0700
@@ -679,12 +679,7 @@
            av = (AV*)SSPOPPTR;
            gv = (GV*)SSPOPPTR;
            if (GvAV(gv)) {
-               AV * const goner = GvAV(gv);
-               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)) {
@@ -697,12 +692,7 @@
            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)) {

==== //depot/maint-5.8/perl/t/op/tie.t#19 (xtext) ====
Index: perl/t/op/tie.t
--- perl/t/op/tie.t#18~30495~   2007-03-07 08:11:42.000000000 -0800
+++ perl/t/op/tie.t     2008-03-11 10:06:04.000000000 -0700
@@ -572,3 +572,19 @@
 }
 EXPECT
 yes
+########
+sub TIEARRAY { bless [], 'main' }
+{
+    local @a;
+    tie @a, 'main';
+}
+print "tied\n" if tied @a;
+EXPECT
+########
+sub TIEHASH { bless [], 'main' }
+{
+    local %h;
+    tie %h, 'main';
+}
+print "tied\n" if tied %h;
+EXPECT
End of Patch.

Reply via email to