From: Gurusamy Sarathy Date: Tue, 15 Feb 2000 04:54:17 +0000 (+0000) Subject: fix memory leak in C<$x = *Y> provoked by change#4198, which X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=850fabdf2ccd0a80b987899ff0014695459be38a;p=p5sagit%2Fp5-mst-13.2.git fix memory leak in C<$x = *Y> provoked by change#4198, which introduced XPVMG storage in arenas p4raw-link: @4198 on //depot/perl: 932e9ff92dfdad82564fe7085f2cb398e628fac3 p4raw-id: //depot/perl@5090 --- diff --git a/sv.c b/sv.c index 9376540..616344b 100644 --- a/sv.c +++ b/sv.c @@ -5224,6 +5224,8 @@ Perl_sv_bless(pTHX_ SV *sv, HV *stash) STATIC void S_sv_unglob(pTHX_ SV *sv) { + void *xpvmg; + assert(SvTYPE(sv) == SVt_PVGV); SvFAKE_off(sv); if (GvGP(sv)) @@ -5235,6 +5237,13 @@ S_sv_unglob(pTHX_ SV *sv) sv_unmagic(sv, '*'); Safefree(GvNAME(sv)); GvMULTI_off(sv); + + /* need to keep SvANY(sv) in the right arena */ + xpvmg = new_XPVMG(); + StructCopy(SvANY(sv), xpvmg, XPVMG); + del_XPVGV(SvANY(sv)); + SvANY(sv) = xpvmg; + SvFLAGS(sv) &= ~SVTYPEMASK; SvFLAGS(sv) |= SVt_PVMG; }