Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
WIP keep immortals in arrays asis
Browse files Browse the repository at this point in the history
i.e. -e"print [!0]->[0]"
See GH #413

Unfortunately we cannot fix the main culprit sv_setsv_flags, as we cannot set the
pointer of dest, only the value. So we need to fix the callers.
The SV values for arrays and hashes.
  • Loading branch information
rurban committed May 18, 2020
1 parent 73cbb17 commit 5f33424
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions av.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,14 @@ Perl_av_make(pTHX_ SSize_t size, SV **strp)

SvGETMAGIC(*strp); /* before newSV, in case it dies */
AvFILLp(av)++;
ary[i] = newSV(0);
sv_setsv_flags(ary[i], *strp,
SV_DO_COW_SVSETSV|SV_NOSTEAL);
/* keep most immortals asis. cperl only. */
if (SvIMMORTAL(*strp)) {
ary[i] = *strp;
} else {
ary[i] = newSV(0);
sv_setsv_flags(ary[i], *strp,
SV_DO_COW_SVSETSV|SV_NOSTEAL);
}
strp++;
}
/* disarm av's leak guard */
Expand Down

0 comments on commit 5f33424

Please sign in to comment.