This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #122799] Always turn off CvNAMED in cvgv-set
authorFather Chrysostomos <sprout@cpan.org>
Sat, 20 Sep 2014 05:15:52 +0000 (22:15 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 20 Sep 2014 14:43:24 +0000 (07:43 -0700)
Instead of turning off the flag only when we need to turn it off
(when there is a hek, which is the only time it should be on), just
turn it off unconditionally.

This gets Scope::Upper working once more.

While it is arguably the module’s fault, it’s still a good idea to
make cvgv_set robust.  CvNAMED should never be on after calling it,
regardless of the previous state of the CV.

gv.c

diff --git a/gv.c b/gv.c
index 73fb7da..04013a5 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -234,10 +234,10 @@ Perl_cvgv_set(pTHX_ CV* cv, GV* gv)
     }
     else if ((hek = CvNAME_HEK(cv))) {
        unshare_hek(hek);
-       CvNAMED_off(cv);
        CvLEXICAL_off(cv);
     }
 
+    CvNAMED_off(cv);
     SvANY(cv)->xcv_gv_u.xcv_gv = gv;
     assert(!CvCVGV_RC(cv));