summaryrefslogtreecommitdiff
path: root/pad.c
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2017-12-30 12:36:54 +0000
committerZefram <zefram@fysh.org>2017-12-30 12:36:54 +0000
commitdce3f5c3fd788f1c2e451e3760f05a347c949eff (patch)
tree34853724ee56bad73e6e3a48115ec33530b1f4d2 /pad.c
parente2bcc7d7ec67c661405135f9b00232631a97f2fb (diff)
downloadperl-dce3f5c3fd788f1c2e451e3760f05a347c949eff.tar.gz
assert nested CV existence when freeing CV
[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.
Diffstat (limited to 'pad.c')
-rw-r--r--pad.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/pad.c b/pad.c
index d1311e2e0b..6ec2e89709 100644
--- a/pad.c
+++ b/pad.c
@@ -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;