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