f6ea51
From dc5c68130b7c8b727e9e792506183c255fc2bc70 Mon Sep 17 00:00:00 2001
f6ea51
From: Tony Cook <tony@develop-help.com>
f6ea51
Date: Thu, 19 Oct 2017 10:46:04 +1100
f6ea51
Subject: [PATCH] (perl #132245) don't try to process a char range with no
f6ea51
 preceding char
f6ea51
MIME-Version: 1.0
f6ea51
Content-Type: text/plain; charset=UTF-8
f6ea51
Content-Transfer-Encoding: 8bit
f6ea51
f6ea51
A range like \N{}-0 eventually results in compilation failing, but
f6ea51
before that, get_and_check_backslash_N_name() attempts to treat
f6ea51
the memory before the empty output of \N{} as a character.
f6ea51
f6ea51
Petr Písař: Ported to 5.26.1.
f6ea51
f6ea51
Signed-off-by: Petr Písař <ppisar@redhat.com>
f6ea51
---
f6ea51
 t/lib/warnings/toke | 5 +++++
f6ea51
 toke.c              | 6 +++---
f6ea51
 2 files changed, 8 insertions(+), 3 deletions(-)
f6ea51
f6ea51
diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke
f6ea51
index fc51d9f..398ee22 100644
f6ea51
--- a/t/lib/warnings/toke
f6ea51
+++ b/t/lib/warnings/toke
f6ea51
@@ -1651,3 +1651,8 @@ Execution of - aborted due to compilation errors.
f6ea51
 use utf8;
f6ea51
 qw∘foo ∞ ♥ bar∘
f6ea51
 EXPECT
f6ea51
+########
f6ea51
+# NAME tr/// range with empty \N{} at the start
f6ea51
+tr//\N{}-0/;
f6ea51
+EXPECT
f6ea51
+Unknown charname '' is deprecated. Its use will be fatal in Perl 5.28 at - line 1.
f6ea51
diff --git a/toke.c b/toke.c
f6ea51
index 6f84d2d..6ee7a68 100644
f6ea51
--- a/toke.c
f6ea51
+++ b/toke.c
f6ea51
@@ -2958,9 +2958,9 @@ S_scan_const(pTHX_ char *start)
f6ea51
 
f6ea51
                 /* Here, we don't think we're in a range.  If the new character
f6ea51
                  * is not a hyphen; or if it is a hyphen, but it's too close to
f6ea51
-                 * either edge to indicate a range, then it's a regular
f6ea51
-                 * character. */
f6ea51
-                if (*s != '-' || s >= send - 1 || s == start) {
f6ea51
+                 * either edge to indicate a range, or if we haven't output any
f6ea51
+                 * characters yet then it's a regular character. */
f6ea51
+                if (*s != '-' || s >= send - 1 || s == start || d == SvPVX(sv)) {
f6ea51
 
f6ea51
                     /* A regular character.  Process like any other, but first
f6ea51
                      * clear any flags */
f6ea51
-- 
f6ea51
2.13.6
f6ea51