Commit
049bd5ffd62b fixed problems with the wrong @_ being visible
after *_ modification followed by goto. In so doing, it made it
possible for a null to be placed at the start of the target sub’s
pad, because it was not checking that the array it got from PL_defgv
was actually non-null. Simply adding the check makes everything work.
to freed memory as the result of undef *_. So put
it in the callee’s pad, donating our refer-
ence count. */
- SvREFCNT_dec(PAD_SVl(0));
- PAD_SVl(0) = (SV *)(cx->blk_sub.argarray = arg);
+ if (arg) {
+ SvREFCNT_dec(PAD_SVl(0));
+ PAD_SVl(0) = (SV *)(cx->blk_sub.argarray = arg);
+ }
/* GvAV(PL_defgv) might have been modified on scope
exit, so restore it. */
use warnings;
use strict;
-plan tests => 92;
+plan tests => 94;
our $TODO;
my $deprecated = 0;
# *_{ARRAY} was untouched, too.
is *_{ARRAY}, undef, 'goto &xsub when @_ does not exist';
+# goto &perlsub when @_ itself does not exist [perl #119949]
+# This was only crashing when the replaced sub call had an argument list.
+# (I.e., &{ sub { goto ... } } did not crash.)
+sub {
+ undef *_;
+ goto sub {
+ is *_{ARRAY}, undef, 'goto &perlsub when @_ does not exist';
+ }
+}->();
+sub {
+ local *_;
+ goto sub {
+ is *_{ARRAY}, undef, 'goto &sub when @_ does not exist (local *_)';
+ }
+}->();
+
+
# [perl #36521] goto &foo in warn handler could defeat recursion avoider
{