diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-11-10 12:04:51 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-11-11 16:13:19 -0800 |
commit | 4571f4a728fcf420c04fe45a1566d6d2f38d76ae (patch) | |
tree | 74c3c49a9eb922035810d4cbc48b473eb32bd371 /gv.c | |
parent | 5deb1341767b498cac376b4d0fcf168a328c2d94 (diff) | |
download | perl-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.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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); } |