From: Tony Cook Date: Wed, 18 Oct 2017 23:47:22 +0000 (+1100) Subject: (perl #132245) don't leak on \N{} X-Git-Tag: v5.27.6~234 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/ebcc725e3f7e5ec8b898a7035ff5c5e2c230522e (perl #132245) don't leak on \N{} get_and_check_backslash_N_name() failed to free its working SV if the name was empty. --- diff --git a/t/op/svleak.t b/t/op/svleak.t index e4e881d..7226dd8 100644 --- a/t/op/svleak.t +++ b/t/op/svleak.t @@ -15,7 +15,7 @@ BEGIN { use Config; -plan tests => 141; +plan tests => 142; # 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 @@ -593,3 +593,8 @@ EOF } ::leak(2, 0, \&named, "Perl_reg_named_buff_fetch() on no-name RE"); } + +{ + sub N_leak { eval 'tr//\N{}-0/' } + ::leak(2, 0, \&N_leak, "a bad \\N{} in a range leaks"); +} diff --git a/toke.c b/toke.c index 68ec96b..a8578e6 100644 --- a/toke.c +++ b/toke.c @@ -2595,6 +2595,7 @@ S_get_and_check_backslash_N_name(pTHX_ const char* s, const char* const e) PERL_ARGS_ASSERT_GET_AND_CHECK_BACKSLASH_N_NAME; if (!SvCUR(res)) { + SvREFCNT_dec_NN(res); /* diag_listed_as: Unknown charname '%s' */ yyerror("Unknown charname ''"); return NULL;