av_extend_guts: set correct ary_offset when unshifting an array (GH#18667)

This commit is contained in:
Richard Leach 2021-04-02 23:51:45 +01:00 committed by Hugo van der Sanden
parent d23c9e49d1
commit ce9f3c9c00
2 changed files with 7 additions and 0 deletions

1
av.c
View File

@ -110,6 +110,7 @@ Perl_av_extend_guts(pTHX_ AV *av, SSize_t key, SSize_t *maxp, SV ***allocp,
if (av && *allocp != *arrayp) { /* a shifted SV* array exists */
to_null = *arrayp - *allocp;
*maxp += to_null;
ary_offset = AvFILLp(av) + 1;
Move(*arrayp, *allocp, AvFILLp(av)+1, SV*);

View File

@ -108,4 +108,10 @@ is sprintf("%s", splice @a, 0, 1, undef), "",
"croak when splicing into readonly array";
}
# GH#18667 - av_extend_guts must zero duplicate SV*s
fresh_perl_is('my @data = (undef) x 4; splice @data, 1, 1;
splice @data, 2, 1; $data[3] = undef; splice @data, 3, 1;',
'', {}, 'GH#18667 - av_extend_guts must zero duplicate SV*s');
done_testing;