diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-08-28 07:24:53 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-08-28 07:24:53 -0700 |
commit | db5cc3ee5bdb14c8d59302b6c3ef8ff4bca660bb (patch) | |
tree | fbe560399f3aa944f0d3891c47ce1144ced910b7 /scope.c | |
parent | 56117e3ef4ef2c7986c400f86f321f22f261571a (diff) | |
download | perl-db5cc3ee5bdb14c8d59302b6c3ef8ff4bca660bb.tar.gz |
Fix crash in leave_scope when my sub has CvGV
Sub declaration can reuse an existing stub. So it is possible to define
a package sub using a stub that was originally lexical. Hence,
leave_scope needs to take into account that a my-sub may not have a
name hek any more.
Diffstat (limited to 'scope.c')
-rw-r--r-- | scope.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -1029,7 +1029,15 @@ Perl_leave_scope(pTHX_ I32 base) break; case SVt_PVCV: { - HEK * const hek = CvNAME_HEK((CV *)sv); + HEK *hek = + CvNAME_HEK((CV *)( + CvNAMED(sv) + ? sv + : mg_find(PadlistNAMESARRAY( + CvPADLIST(find_runcv(NULL)) + )[svp-PL_curpad], + PERL_MAGIC_proto + )->mg_obj)); assert(hek); share_hek_hek(hek); cv_undef((CV *)sv); @@ -1059,9 +1067,15 @@ Perl_leave_scope(pTHX_ I32 base) *svp = newSV_type(SVt_PVCV); /* Share name */ - assert(CvNAMED(sv)); CvNAME_HEK_set(*svp, - share_hek_hek(CvNAME_HEK((CV *)sv))); + share_hek_hek(CvNAME_HEK((CV *)( + CvNAMED(sv) + ? sv + : mg_find(PadlistNAMESARRAY( + CvPADLIST(find_runcv(NULL)) + )[svp-PL_curpad], + PERL_MAGIC_proto + )->mg_obj)))); break; } default: *svp = newSV(0); break; |