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