diff options
Diffstat (limited to 'pad.c')
-rw-r--r-- | pad.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -257,11 +257,19 @@ Perl_pad_undef(pTHX_ CV* cv) && CvOUTSIDE(innercv) == cv) { assert(CvWEAKOUTSIDE(innercv)); - CvWEAKOUTSIDE_off(innercv); - CvOUTSIDE(innercv) = outercv; - CvOUTSIDE_SEQ(innercv) = seq; - SvREFCNT_inc(outercv); + /* don't relink to grandfather if he's being freed */ + if (outercv && SvREFCNT(outercv)) { + CvWEAKOUTSIDE_off(innercv); + CvOUTSIDE(innercv) = outercv; + CvOUTSIDE_SEQ(innercv) = seq; + SvREFCNT_inc(outercv); + } + else { + CvOUTSIDE(innercv) = Nullcv; + } + } + } } } |