This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
small code tweak in Perl_gv_init
authorDavid Mitchell <davem@iabyn.com>
Sat, 24 Jul 2010 15:11:12 +0000 (16:11 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sat, 24 Jul 2010 15:12:30 +0000 (16:12 +0100)
(follow-up to previous commit, fix for #76540)

gv.c

diff --git a/gv.c b/gv.c
index a50878f..6f63f4b 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -296,6 +296,7 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi)
 
            /* newCONSTSUB takes ownership of the reference from us.  */
            cv = newCONSTSUB(stash, (name0 ? name0 : name), has_constant);
+           assert(GvCV(gv) == cv); /* newCONSTSUB should have set this */
            if (name0)
                Safefree(name0);
            /* If this reference was a copy of another, then the subroutine
@@ -306,8 +307,8 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi)
        } else {
            (void) start_subparse(0,0); /* Create empty CV in compcv. */
            cv = PL_compcv;
+           GvCV(gv) = cv;
        }
-       GvCV(gv) = cv;
        LEAVE;
 
         mro_method_changed_in(GvSTASH(gv)); /* sub Foo::bar($) { (shift) } sub ASDF::baz($); *ASDF::baz = \&Foo::bar */