Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions av.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ Perl_av_make(pTHX_ SSize_t size, SV **strp)
AvALLOC(av) = ary;
AvARRAY(av) = ary;
AvMAX(av) = size - 1;
SSize_t *fillp = &AvFILLp(av);

/* avoid av being leaked if croak when calling magic below */
EXTEND_MORTAL(1);
PL_tmps_stack[++PL_tmps_ix] = (SV*)av;
Expand All @@ -486,12 +488,8 @@ Perl_av_make(pTHX_ SSize_t size, SV **strp)
/* Don't let sv_setsv swipe, since our source array might
have multiple references to the same temp scalar (e.g.
from a list slice) */

SvGETMAGIC(*strp); /* before newSV, in case it dies */
AvFILLp(av)++;
ary[i] = newSV_type(SVt_NULL);
sv_setsv_flags(ary[i], *strp,
SV_DO_COW_SVSETSV|SV_NOSTEAL);
ary[i] = newSVsv_flags(*strp, SV_DO_COW_SVSETSV|SV_NOSTEAL|SV_GMAGIC);
*fillp = i;
strp++;
}
/* disarm av's leak guard */
Expand Down
5 changes: 4 additions & 1 deletion embed.fnc
Original file line number Diff line number Diff line change
Expand Up @@ -2347,7 +2347,10 @@ ARdp |OP * |newSVREF |NN OP *o
Adp |SV * |newSVrv |NN SV * const rv \
|NULLOK const char * const classname
ARdmp |SV * |newSVsv |NULLOK SV * const old
ARdp |SV * |newSVsv_flags |NULLOK SV * const old \
ARdip |SV * |newSVsv_flags |NULLOK SV * const old \
|I32 flags
ARdp |SV * |newSVsv_flags_NN \
|NN SV * const old \
|I32 flags
ARdmp |SV * |newSVsv_nomg |NULLOK SV * const old
ARdp |SV * |newSV_true
Expand Down
1 change: 1 addition & 0 deletions embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@
# define newSVpvz(a) Perl_newSVpvz(aTHX_ a)
# define newSVrv(a,b) Perl_newSVrv(aTHX_ a,b)
# define newSVsv_flags(a,b) Perl_newSVsv_flags(aTHX_ a,b)
# define newSVsv_flags_NN(a,b) Perl_newSVsv_flags_NN(aTHX_ a,b)
# define newSVuv(a) Perl_newSVuv(aTHX_ a)
# define newTRYCATCHOP(a,b,c,d) Perl_newTRYCATCHOP(aTHX_ a,b,c,d)
# define newUNOP(a,b,c) Perl_newUNOP(aTHX_ a,b,c)
Expand Down
13 changes: 13 additions & 0 deletions pod/perldelta.pod
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,19 @@ memory saving is unrealistic.
C<sv_vcatpvfn_flags()> now substitutes the Unicode REPLACEMENT CHARACTER
for malformed input. Previously it used the NUL character.

=item *

L<perlapi/C<newSVsv_flags_NN>> is a new function for creating a new SV
and assigning the value(s) of an existing SV to it.

Historically, C<Perl_newSVsv_flags> and C<Perl_sv_mortalcopy_flags> would
pass a new SV head and the original SV to C<Perl_sv_setsv_flags>. However,
the latter contains many branches of no relevance to a fresh SV, so they
now make use of the new function to streamline the process.

C<Perl_newSVsv_flags> is now essentially a NULL pointer check and wrapper
around the new function, so has been moved into F<sv_inline.h>.

=back

=head1 Selected Bug Fixes
Expand Down
9 changes: 5 additions & 4 deletions pp.c
Original file line number Diff line number Diff line change
Expand Up @@ -6419,10 +6419,11 @@ PP(pp_push)
PL_delaymagic = DM_DELAY;
for (++MARK; MARK <= PL_stack_sp; MARK++) {
SV *sv;
if (*MARK) SvGETMAGIC(*MARK);
sv = newSV_type(SVt_NULL);
if (*MARK)
sv_setsv_nomg(sv, *MARK);
if (*MARK) {
sv = newSVsv_flags(*MARK, SV_DO_COW_SVSETSV|SV_GMAGIC);
} else
sv = newSV_type(SVt_NULL);

av_store(ary, AvFILLp(ary)+1, sv);
}
if (PL_delaymagic & DM_ARRAY_ISA)
Expand Down
9 changes: 3 additions & 6 deletions pp_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4418,13 +4418,11 @@ S_doopen_pm(pTHX_ SV *name)
return NULL;

if (memENDPs(p, namelen, ".pm")) {
SV *const pmcsv = sv_newmortal();
PerlIO * pmcio;
SV *const pmcsv = sv_mortalcopy_flags(name, SV_GMAGIC|SV_NOSTEAL|SV_DO_COW_SVSETSV);

SvSetSV_nosteal(pmcsv,name);
sv_catpvs(pmcsv, "c");

pmcio = check_type_and_open(pmcsv);
PerlIO * pmcio = check_type_and_open(pmcsv);
if (pmcio)
return pmcio;
}
Expand Down Expand Up @@ -4816,8 +4814,7 @@ S_require_file(pTHX_ SV *sv)
}

if (SvPADTMP(nsv)) {
nsv = sv_newmortal();
SvSetSV_nosteal(nsv,sv);
nsv = sv_mortalcopy_flags(sv, SV_GMAGIC|SV_NOSTEAL|SV_DO_COW_SVSETSV);
}

const char *method = NULL;
Expand Down
3 changes: 1 addition & 2 deletions pp_hot.c
Original file line number Diff line number Diff line change
Expand Up @@ -5374,8 +5374,7 @@ PP(pp_subst)
if (dstr) {
/* replacement needing upgrading? */
if (DO_UTF8(TARG) && !doutf8) {
nsv = sv_newmortal();
SvSetSV(nsv, dstr);
nsv = sv_mortalcopy_flags(dstr, SV_GMAGIC|SV_DO_COW_SVSETSV);
sv_utf8_upgrade(nsv);
c = SvPV_const(nsv, clen);
doutf8 = TRUE;
Expand Down
10 changes: 8 additions & 2 deletions proto.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading