This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
cv_clone: panic for no pad
authorFather Chrysostomos <sprout@cpan.org>
Fri, 3 Aug 2012 16:29:38 +0000 (09:29 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 16 Sep 2012 05:45:04 +0000 (22:45 -0700)
cv_clone has serendipitously gained the ability to clone CVs without
pads.  It is not clear that we want to add this ability to this API
function, because we would be stuck supporting it, even if we came up
with a better interface.  It used to crash or fail an assertion if
there was no pad.

pad.c

diff --git a/pad.c b/pad.c
index 6218498..d320004 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -2137,6 +2137,7 @@ Perl_cv_clone(pTHX_ CV *proto)
 {
     PERL_ARGS_ASSERT_CV_CLONE;
 
+    if (!CvPADLIST(proto)) Perl_croak(aTHX_ "panic: no pad in cv_clone");
     return S_cv_clone(aTHX_ proto, NULL, NULL);
 }