Skip to content

Commit

Permalink
(perl #132245) don't try to process a char range with no preceding char
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tonycoz committed Oct 29, 2017
1 parent 6e8135a commit e8d55f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions t/lib/croak/toke
Expand Up @@ -413,3 +413,9 @@ EXPECT
Illegal operator following parameter in a subroutine signature at - line 3, near "($a += 1"
syntax error at - line 3, near "($a += 1"
Execution of - aborted due to compilation errors.
########
# NAME tr/// range with empty \N{} at the start
tr//\N{}-0/;
EXPECT
Unknown charname '' at - line 1, within string
Execution of - aborted due to compilation errors.
6 changes: 3 additions & 3 deletions toke.c
Expand Up @@ -2969,9 +2969,9 @@ S_scan_const(pTHX_ char *start)

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

/* A regular character. Process like any other, but first
* clear any flags */
Expand Down

0 comments on commit e8d55f2

Please sign in to comment.