Those require() calls are compiled as BASEOPs, so it is invalid to look for
their op_first member when they are translated to a call to the global
override subroutine. The new entersub call should get $_ in its argument
list instead.
This fixes [perl #78260].
}
if (gv && GvCVu(gv) && GvIMPORTED_CV(gv)) {
- OP * const kid = cUNOPo->op_first;
- OP * newop;
-
- cUNOPo->op_first = 0;
+ OP *kid, *newop;
+ if (o->op_flags & OPf_KIDS) {
+ kid = cUNOPo->op_first;
+ cUNOPo->op_first = NULL;
+ }
+ else {
+ kid = newDEFSVOP();
+ }
#ifndef PERL_MAD
op_free(o);
#endif
C<Internals::SvREFCNT> now behaves consistently in 'get' and 'set' scenarios
[perl #103222] and also treats the reference count as unsigned.
+=item *
+
+Calling C<require> on an implicit C<$_> when C<*CORE::GLOBAL::require> has
+been overridden does not segfault anymore, and C<$_> is now passed to the
+overriding subroutine [perl #78260].
+
=back
=head1 Acknowledgements
require './test.pl';
}
-plan tests => 26;
+plan tests => 28;
#
# This file tries to test builtin override using CORE::GLOBAL
eval "use 5.006";
is( $r, "5.006" );
+{
+ local $_ = 'foo.pm';
+ require;
+ is( $r, 'foo.pm' );
+}
+
+{
+ my $_ = 'bar.pm';
+ require;
+ is( $r, 'bar.pm' );
+}
+
# localizing *CORE::GLOBAL::foo should revert to finding CORE::foo
{
local(*CORE::GLOBAL::require);