perl-Object-Pad/Object-Pad-0.47-rt137952.patch

48 lines
1.2 KiB
Diff

From: leonerd-cpan [...] leonerd.org.uk
https://rt.cpan.org/Public/Bug/Display.html?id=137952
--- old/src/class.c 2021-07-30 17:08:56 +0000
+++ new/src/class.c 2021-07-31 12:55:46 +0000
@@ -87,6 +87,9 @@
#define embed_cv(cv, embedding) S_embed_cv(aTHX_ cv, embedding)
static CV *S_embed_cv(pTHX_ CV *cv, RoleEmbedding *embedding)
{
+ assert(cv);
+ assert(CvOUTSIDE(cv));
+
CV *embedded_cv = cv_clone(cv);
SV *embeddingsv = embedding->embeddingsv;
@@ -358,6 +361,19 @@
ENTER;
+ if(!PL_compcv) {
+ /* We require the initslots CV to have a CvOUTSIDE, or else cv_clone()
+ * will segv when we compose role slots. Any class dynamically generated
+ * by string eval() will likely not get one, because it won't inherit a
+ * PL_compcv here. We'll fake it up
+ * See also https://rt.cpan.org/Ticket/Display.html?id=137952
+ */
+ SAVEVPTR(PL_compcv);
+ PL_compcv = find_runcv(0);
+
+ assert(PL_compcv);
+ }
+
I32 floor_ix = start_subparse(FALSE, 0);
SAVEFREESV(PL_compcv);
@@ -519,6 +535,9 @@
meta->initslots = newATTRSUB(floor_ix, NULL, NULL, NULL, ops);
+ assert(meta->initslots);
+ assert(CvOUTSIDE(meta->initslots));
+
LEAVE;
}