Skip to content

Commit e8d55f2

Browse files
committed
(perl #132245) don't try to process a char range with no preceding char
A range like \N{}-0 eventually results in compilation failing, but before that, get_and_check_backslash_N_name() attempts to treat the memory before the empty output of \N{} as a character.
1 parent 6e8135a commit e8d55f2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

t/lib/croak/toke

+6
Original file line numberDiff line numberDiff line change
@@ -413,3 +413,9 @@ EXPECT
413413
Illegal operator following parameter in a subroutine signature at - line 3, near "($a += 1"
414414
syntax error at - line 3, near "($a += 1"
415415
Execution of - aborted due to compilation errors.
416+
########
417+
# NAME tr/// range with empty \N{} at the start
418+
tr//\N{}-0/;
419+
EXPECT
420+
Unknown charname '' at - line 1, within string
421+
Execution of - aborted due to compilation errors.

toke.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -2969,9 +2969,9 @@ S_scan_const(pTHX_ char *start)
29692969

29702970
/* Here, we don't think we're in a range. If the new character
29712971
* is not a hyphen; or if it is a hyphen, but it's too close to
2972-
* either edge to indicate a range, then it's a regular
2973-
* character. */
2974-
if (*s != '-' || s >= send - 1 || s == start) {
2972+
* either edge to indicate a range, or if we haven't output any
2973+
* characters yet then it's a regular character. */
2974+
if (*s != '-' || s >= send - 1 || s == start || d == SvPVX(sv)) {
29752975

29762976
/* A regular character. Process like any other, but first
29772977
* clear any flags */

0 commit comments

Comments
 (0)