From 8ca8859f11d3a842e8fc7a0c1d2bb21e709d5a3b Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Tue, 13 Nov 2012 23:41:19 -0800 Subject: [PATCH] Stop my subs with syntax errors from leaking --- op.c | 2 ++ t/op/svleak.t | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/op.c b/op.c index b3ac10d..3480a6c 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 0b4db43..c365709 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, '"${<