summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-08-28 07:24:53 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-08-28 07:24:53 -0700
commitdb5cc3ee5bdb14c8d59302b6c3ef8ff4bca660bb (patch)
treefbe560399f3aa944f0d3891c47ce1144ced910b7 /scope.c
parent56117e3ef4ef2c7986c400f86f321f22f261571a (diff)
downloadperl-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.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/scope.c b/scope.c
index 5cfd78bba6..66589abc5b 100644
--- a/scope.c
+++ b/scope.c
@@ -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;