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