summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-11-10 12:04:51 -0800
committerFather Chrysostomos <sprout@cpan.org>2013-11-11 16:13:19 -0800
commit4571f4a728fcf420c04fe45a1566d6d2f38d76ae (patch)
tree74c3c49a9eb922035810d4cbc48b473eb32bd371 /gv.c
parent5deb1341767b498cac376b4d0fcf168a328c2d94 (diff)
downloadperl-4571f4a728fcf420c04fe45a1566d6d2f38d76ae.tar.gz
Undeffing a gv in DESTROY triggered by undeffing the same gv
$ ./perl -Ilib -e 'sub foo{} bless \&foo; DESTROY { undef *foo } undef *foo' Attempt to free unreferenced glob pointers, Perl interpreter: 0x7fd6a3803200 at -e line 1. Lowering the reference count on the glob pointer only after freeing the contents fixes this.
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/gv.c b/gv.c
index 1c86029d84..d29b1ef3cd 100644
--- a/gv.c
+++ b/gv.c
@@ -2351,9 +2351,10 @@ Perl_gp_free(pTHX_ GV *gv)
pTHX__FORMAT pTHX__VALUE);
return;
}
- if (--gp->gp_refcnt > 0) {
+ if (gp->gp_refcnt > 1) {
if (gp->gp_egv == gv)
gp->gp_egv = 0;
+ gp->gp_refcnt--;
GvGP_set(gv, NULL);
return;
}
@@ -2411,6 +2412,7 @@ Perl_gp_free(pTHX_ GV *gv)
}
}
+ gp->gp_refcnt--;
Safefree(gp);
GvGP_set(gv, NULL);
}