When a filetest op returns false, it skips past following ops that
are stacked filetests. The code to do this was assuming that op_next
would always be non-null, which is not always the case, for example in
a sort comparator. Allow for it to be null. Fixes [perl #129347].
PUTBACK;
if (PL_op->op_private & OPpFT_STACKING) {
- while (OP_IS_FILETEST(next->op_type)
+ while (next && OP_IS_FILETEST(next->op_type)
&& next->op_private & OPpFT_STACKED)
next = next->op_next;
}
my @ops = split //, 'rwxoRWXOezsfdlpSbctugkTMBAC';
-plan( tests => @ops * 5 );
+plan( tests => @ops * 5 + 1 );
package o { use overload '-X' => sub { 1 } }
my $o = bless [], 'o';
my @foo = eval "-$op \$o";
is @foo, 1, "-$op \$overld did not leave \$overld on the stack";
}
+
+{
+ # [perl #129347] cope with stacked filetests where PL_op->op_next is null
+ () = sort { -d -d } \*TEST0, \*TEST1;
+ ok 1, "survived stacked filetests with null op_next";
+}