diff options
-rw-r--r-- | op.c | 12 | ||||
-rw-r--r-- | pod/perldelta.pod | 6 | ||||
-rw-r--r-- | t/op/override.t | 14 |
3 files changed, 27 insertions, 5 deletions
@@ -8588,10 +8588,14 @@ Perl_ck_require(pTHX_ OP *o) } 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 diff --git a/pod/perldelta.pod b/pod/perldelta.pod index b9e3631495..1e6c7eac17 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -580,6 +580,12 @@ the warnings would occur if enabled in the comparison routine's scope. 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 diff --git a/t/op/override.t b/t/op/override.t index 413ba77e84..ab2cbf1515 100644 --- a/t/op/override.t +++ b/t/op/override.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 26; +plan tests => 28; # # This file tries to test builtin override using CORE::GLOBAL @@ -52,6 +52,18 @@ is( $r, join($dirsep, "Foo", "Bar.pm") ); 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); |