b2938d
From f877e124a20d4f94c82c36e6b7a99b4e9663e204 Mon Sep 17 00:00:00 2001
b2938d
From: Tony Cook <tony@develop-help.com>
b2938d
Date: Tue, 10 Nov 2020 15:50:27 +1100
b2938d
Subject: [PATCH] fetch magic on the first stacked filetest, not the last
b2938d
MIME-Version: 1.0
b2938d
Content-Type: text/plain; charset=UTF-8
b2938d
Content-Transfer-Encoding: 8bit
b2938d
b2938d
fixes #18293
b2938d
b2938d
Signed-off-by: Petr Písař <ppisar@redhat.com>
b2938d
---
b2938d
 pp_sys.c        |  2 +-
b2938d
 t/op/filetest.t | 10 +++++++++-
b2938d
 2 files changed, 10 insertions(+), 2 deletions(-)
b2938d
b2938d
diff --git a/pp_sys.c b/pp_sys.c
b2938d
index 66c5d9aade..5c9f768eaf 100644
b2938d
--- a/pp_sys.c
b2938d
+++ b/pp_sys.c
b2938d
@@ -3067,7 +3067,7 @@ S_try_amagic_ftest(pTHX_ char chr) {
b2938d
     SV *const arg = *PL_stack_sp;
b2938d
 
b2938d
     assert(chr != '?');
b2938d
-    if (!(PL_op->op_private & OPpFT_STACKING)) SvGETMAGIC(arg);
b2938d
+    if (!(PL_op->op_private & OPpFT_STACKED)) SvGETMAGIC(arg);
b2938d
 
b2938d
     if (SvAMAGIC(arg))
b2938d
     {
b2938d
diff --git a/t/op/filetest.t b/t/op/filetest.t
b2938d
index fe9724c59a..7c471c050c 100644
b2938d
--- a/t/op/filetest.t
b2938d
+++ b/t/op/filetest.t
b2938d
@@ -9,7 +9,7 @@ BEGIN {
b2938d
     set_up_inc(qw '../lib ../cpan/Perl-OSType/lib');
b2938d
 }
b2938d
 
b2938d
-plan(tests => 57 + 27*14);
b2938d
+plan(tests => 58 + 27*14);
b2938d
 
b2938d
 if ($^O =~ /MSWin32|cygwin|msys/ && !is_miniperl) {
b2938d
   require Win32; # for IsAdminUser()
b2938d
@@ -385,3 +385,11 @@ SKIP: {
b2938d
     ok(!-f "TEST\0-", '-f on name with \0');
b2938d
     ok(!-r "TEST\0-", '-r on name with \0');
b2938d
 }
b2938d
+
b2938d
+{
b2938d
+    # github #18293
b2938d
+    "" =~ /(.*)/;
b2938d
+    my $x = $1; # call magic on $1, setting the pv to ""
b2938d
+    "test.pl" =~ /(.*)/;
b2938d
+    ok(-f -r $1, "stacked handles on a name with magic");
b2938d
+}
b2938d
-- 
b2938d
2.25.4
b2938d