Don’t double-free GVs in gv:S_maybe_add_coresub
authorFather Chrysostomos <sprout@cpan.org>
Sun, 1 Jan 2012 22:19:54 +0000 (14:19 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 1 Jan 2012 22:19:54 +0000 (14:19 -0800)
Commit 8756617677 did not take into account that newSVOP steals a ref-
erence count.

gv.c

diff --git a/gv.c b/gv.c
index 3005895..df3735a 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -517,7 +517,7 @@ S_maybe_add_coresub(pTHX_ HV * const stash, GV *gv,
     if (ampable) {
        CvLVALUE_on(cv);
        newATTRSUB(oldsavestack_ix,
-                  newSVOP(OP_CONST, 0, (SV *)gv),
+                  newSVOP(OP_CONST, 0, SvREFCNT_inc_simple_NN(gv)),
                   NULL,NULL,
                   coresub_op(
                     opnum