summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-02-15 04:54:17 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-02-15 04:54:17 +0000
commit850fabdf2ccd0a80b987899ff0014695459be38a (patch)
tree6f9adcc4c71d8a3dc9bebf4299fde8ed5ffeb52e /sv.c
parentd4777f279225b24fa563b5d349bba036eebe5439 (diff)
downloadperl-850fabdf2ccd0a80b987899ff0014695459be38a.tar.gz
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
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sv.c b/sv.c
index 9376540a8a..616344b33d 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;
}