2f5d87e
From be05b2f7a801ae1721641fd240e0d7d6fc018136 Mon Sep 17 00:00:00 2001
2f5d87e
From: Aaron Crane <arc@cpan.org>
2f5d87e
Date: Sun, 19 Feb 2017 12:26:54 +0000
2f5d87e
Subject: [PATCH] fix ck_return null-pointer deref on malformed code
2f5d87e
MIME-Version: 1.0
2f5d87e
Content-Type: text/plain; charset=UTF-8
2f5d87e
Content-Transfer-Encoding: 8bit
2f5d87e
2f5d87e
Ported to 5.24.1:
2f5d87e
2f5d87e
commit e5c165a0b7551ffb94661aa7f18aabadba257782
2f5d87e
Author: Aaron Crane <arc@cpan.org>
2f5d87e
Date:   Sun Feb 19 12:26:54 2017 +0000
2f5d87e
2f5d87e
    [perl #130815] fix ck_return null-pointer deref on malformed code
2f5d87e
2f5d87e
commit 9de2a80ffc0eefb4d60e13766baf4bad129e0a92
2f5d87e
Author: David Mitchell <davem@iabyn.com>
2f5d87e
Date:   Sun Feb 19 12:36:58 2017 +0000
2f5d87e
2f5d87e
    bump test count in t/comp/parser.t
2f5d87e
2f5d87e
    (the previous commit forgot to)
2f5d87e
2f5d87e
Signed-off-by: Petr Písař <ppisar@redhat.com>
2f5d87e
---
2f5d87e
 op.c            | 2 +-
2f5d87e
 t/comp/parser.t | 8 +++++++-
2f5d87e
 2 files changed, 8 insertions(+), 2 deletions(-)
2f5d87e
2f5d87e
diff --git a/op.c b/op.c
2f5d87e
index 018d90c..9a61ea7 100644
2f5d87e
--- a/op.c
2f5d87e
+++ b/op.c
2f5d87e
@@ -10695,7 +10695,7 @@ Perl_ck_return(pTHX_ OP *o)
2f5d87e
     PERL_ARGS_ASSERT_CK_RETURN;
2f5d87e
 
2f5d87e
     kid = OpSIBLING(cLISTOPo->op_first);
2f5d87e
-    if (CvLVALUE(PL_compcv)) {
2f5d87e
+    if (PL_compcv && CvLVALUE(PL_compcv)) {
2f5d87e
 	for (; kid; kid = OpSIBLING(kid))
2f5d87e
 	    op_lvalue(kid, OP_LEAVESUBLV);
2f5d87e
     }
2f5d87e
diff --git a/t/comp/parser.t b/t/comp/parser.t
2f5d87e
index 50f601c..5016509 100644
2f5d87e
--- a/t/comp/parser.t
2f5d87e
+++ b/t/comp/parser.t
2f5d87e
@@ -8,7 +8,7 @@ BEGIN {
2f5d87e
     chdir 't' if -d 't';
2f5d87e
 }
2f5d87e
 
2f5d87e
-print "1..173\n";
2f5d87e
+print "1..174\n";
2f5d87e
 
2f5d87e
 sub failed {
2f5d87e
     my ($got, $expected, $name) = @_;
2f5d87e
@@ -546,6 +546,12 @@ eval "grep+grep";
2f5d87e
 eval 'qq{@{0]}${}},{})';
2f5d87e
 is(1, 1, "RT #124207");
2f5d87e
 
2f5d87e
+# RT #130815: crash in ck_return for malformed code
2f5d87e
+{
2f5d87e
+    eval 'm(@{if(0){sub d{]]])}return';
2f5d87e
+    like $@, qr/^syntax error at \(eval \d+\) line 1, near "\{\]"/,
2f5d87e
+        'RT #130815: null pointer deref';
2f5d87e
+}
2f5d87e
 
2f5d87e
 # Add new tests HERE (above this line)
2f5d87e
 
2f5d87e
-- 
2f5d87e
2.7.4
2f5d87e