Skip to content

Commit

Permalink
assert nested CV existence when freeing CV
Browse files Browse the repository at this point in the history
[perl #131631] has a convoluted test case that messes up parser error
recovery and causes a segv via null pointer dereference.  Turn the segv
into an assertion failure, by asserting non-nullness of the pointer.
This doesn't fix the actual problem with error recovery.
  • Loading branch information
Zefram committed Dec 30, 2017
1 parent e2bcc7d commit dce3f5c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pad.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,11 @@ Perl_cv_undef_flags(pTHX_ CV *cv, U32 flags)
if (name && PadnamePV(name) && *PadnamePV(name) == '&')
{
CV * const innercv = MUTABLE_CV(curpad[ix]);
U32 inner_rc = SvREFCNT(innercv);
assert(inner_rc);
U32 inner_rc;
assert(innercv);
assert(SvTYPE(innercv) != SVt_PVFM);
inner_rc = SvREFCNT(innercv);
assert(inner_rc);

if (SvREFCNT(comppad) < 2) { /* allow for /(?{ sub{} })/ */
curpad[ix] = NULL;
Expand Down

0 comments on commit dce3f5c

Please sign in to comment.