summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2018-02-13 13:36:22 -0800
committerFather Chrysostomos <sprout@cpan.org>2018-02-18 16:25:42 -0800
commit7406cffe8ec122fcc2500115f8ed1742385893e1 (patch)
tree85cd52b856bf70d6a188cf3d1c166c38f15b5138 /pp_hot.c
parentc46431c409d5cdb3c1c17c039a19e0e03356c7a6 (diff)
downloadperl-7406cffe8ec122fcc2500115f8ed1742385893e1.tar.gz
Fix two bugs when calling &xsub when @_ has holes
This fixes #132729 in the particular instance where an XSUB is called via ampersand syntax when @_ has ‘holes’, or nonexistent ele- ments, as in: @_ = (); $_[1] = 1; &xsub; This means that if the XSUB or something it calls unshifts @_, the first argument passed to the XSUB will now refer to $_[1], not $_[0]; i.e., as of this commit it is correctly shifted over. Previously, a ‘defelem’ was used, which is a magical scalar that remembers its index in the array, independent of whether the array was shifted. In addition, the old code failed to mortalize the defelem, so this commit fixes a memory leak with the new ‘non-elem’ mechanism (a spe- cially-marked element stored in the array itself).
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 9135e5d2d3..24c86e46fe 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -5215,7 +5215,7 @@ PP(pp_entersub)
else sv = AvARRAY(av)[i];
if (sv) SP[i+1] = sv;
else {
- SP[i+1] = newSVavdefelem(av, i, 1);
+ SP[i+1] = av_nonelem(av, i);
}
}
SP += items;