summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--op.c2
-rw-r--r--t/op/svleak.t4
2 files changed, 5 insertions, 1 deletions
diff --git a/op.c b/op.c
index b3ac10d3d1..3480a6c20e 100644
--- a/op.c
+++ b/op.c
@@ -6970,6 +6970,8 @@ Perl_newMYSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
if (PL_parser && PL_parser->error_count) {
op_free(block);
+ SvREFCNT_dec(PL_compcv);
+ PL_compcv = 0;
goto done;
}
diff --git a/t/op/svleak.t b/t/op/svleak.t
index 0b4db4391a..c365709f73 100644
--- a/t/op/svleak.t
+++ b/t/op/svleak.t
@@ -15,7 +15,7 @@ BEGIN {
use Config;
-plan tests => 68;
+plan tests => 69;
# run some code N times. If the number of SVs at the end of loop N is
# greater than (N-1)*delta at the end of loop 1, we've got a leak
@@ -194,6 +194,8 @@ eleak(2, 0, 'sub', '"sub" with nothing following');
eleak(2, 0, '+sub:a{}', 'anon subs with invalid attributes');
eleak(2, 0, 'no warnings; sub a{1 1}', 'sub with syntax error');
eleak(2, 0, 'no warnings; sub {1 1}', 'anon sub with syntax error');
+eleak(2, 0, 'no warnings; use feature ":all"; my sub a{1 1}',
+ 'my sub with syntax error');
# Syntax errors
eleak(2, 0, '"${<<END}"