Permalink
Browse files

(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.
  • Loading branch information...
tonycoz committed Oct 18, 2017
1 parent 6e8135a commit e8d55f27af460b2aea0e4f6867acad7ae6e154cc
Showing with 9 additions and 3 deletions.
  1. +6 −0 t/lib/croak/toke
  2. +3 −3 toke.c
View
@@ -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.
View
6 toke.c
@@ -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 */

0 comments on commit e8d55f2

Please sign in to comment.