summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2010-07-18 16:21:03 +0100
committerDavid Mitchell <davem@iabyn.com>2010-07-18 18:39:18 +0100
commitc794ca97ff43be078aabf556aa282af208d9c38c (patch)
treeb64762c446394bee68df369d68966f9b15452c60 /gv.c
parentcfc1e951d98ba2b9a0e066aba9aadba4cd919eec (diff)
downloadperl-c794ca97ff43be078aabf556aa282af208d9c38c.tar.gz
change when to make CvGV refcounted
Rather than making CvGV refcounted if the CV is anon, decide based on whether the GV pointed to by CvGV holds a reference back to us. Normally these two will be equivalent, but this way is more robust if people are doing weird things. Also spotted an error with cv_clone not clearing the CVf_CVGV_RC flag on the newly cloned cv. This shouldn't normally matter as it will get set shortly anyway, but best to keep things logically correct.
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/gv.c b/gv.c
index 9eaf76c240..917cfb7ee9 100644
--- a/gv.c
+++ b/gv.c
@@ -216,17 +216,17 @@ Perl_cvgv_set(pTHX_ CV* cv, GV* gv)
}
CvGV(cv) = gv;
+ assert(!CvCVGV_RC(cv));
if (!gv)
return;
- if (CvANON(cv)) {
+ if (isGV_with_GP(gv) && GvGP(gv) && (GvCV(gv) == cv || GvFORM(gv) == cv))
+ Perl_sv_add_backref(aTHX_ MUTABLE_SV(gv), MUTABLE_SV(cv));
+ else {
CvCVGV_RC_on(cv);
SvREFCNT_inc_simple_void_NN(gv);
}
- else {
- Perl_sv_add_backref(aTHX_ MUTABLE_SV(gv), MUTABLE_SV(cv));
- }
}