Skip to content

Commit ebcc725

Browse files
committed
(perl #132245) don't leak on \N{}
get_and_check_backslash_N_name() failed to free its working SV if the name was empty.
1 parent e8d55f2 commit ebcc725

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

t/op/svleak.t

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ BEGIN {
1515

1616
use Config;
1717

18-
plan tests => 141;
18+
plan tests => 142;
1919

2020
# run some code N times. If the number of SVs at the end of loop N is
2121
# greater than (N-1)*delta at the end of loop 1, we've got a leak
@@ -593,3 +593,8 @@ EOF
593593
}
594594
::leak(2, 0, \&named, "Perl_reg_named_buff_fetch() on no-name RE");
595595
}
596+
597+
{
598+
sub N_leak { eval 'tr//\N{}-0/' }
599+
::leak(2, 0, \&N_leak, "a bad \\N{} in a range leaks");
600+
}

toke.c

+1
Original file line numberDiff line numberDiff line change
@@ -2595,6 +2595,7 @@ S_get_and_check_backslash_N_name(pTHX_ const char* s, const char* const e)
25952595
PERL_ARGS_ASSERT_GET_AND_CHECK_BACKSLASH_N_NAME;
25962596

25972597
if (!SvCUR(res)) {
2598+
SvREFCNT_dec_NN(res);
25982599
/* diag_listed_as: Unknown charname '%s' */
25992600
yyerror("Unknown charname ''");
26002601
return NULL;

0 commit comments

Comments
 (0)