This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #130815] fix ck_return null-pointer deref on malformed code
authorAaron Crane <arc@cpan.org>
Sun, 19 Feb 2017 12:26:54 +0000 (12:26 +0000)
committerAaron Crane <arc@cpan.org>
Sun, 19 Feb 2017 12:26:54 +0000 (12:26 +0000)
op.c
t/comp/parser.t

diff --git a/op.c b/op.c
index dca52e2..abe32e7 100644 (file)
--- a/op.c
+++ b/op.c
@@ -10988,7 +10988,7 @@ Perl_ck_return(pTHX_ OP *o)
     PERL_ARGS_ASSERT_CK_RETURN;
 
     kid = OpSIBLING(cLISTOPo->op_first);
-    if (CvLVALUE(PL_compcv)) {
+    if (PL_compcv && CvLVALUE(PL_compcv)) {
        for (; kid; kid = OpSIBLING(kid))
            op_lvalue(kid, OP_LEAVESUBLV);
     }
index 8be973b..570df2e 100644 (file)
@@ -598,6 +598,12 @@ is $@, "", 'substr keys assignment';
     like $@, qr/Missing right curly or square bracket/, 'RT #130311';
 }
 
+# RT #130815: crash in ck_return for malformed code
+{
+    eval 'm(@{if(0){sub d{]]])}return';
+    like $@, qr/^syntax error at \(eval \d+\) line 1, near "\{\]"/,
+        'RT #130815: null pointer deref';
+}
 
 # Add new tests HERE (above this line)