From b6434e34455153147a326fd1fbf0163bf6179fdf Mon Sep 17 00:00:00 2001 From: Richard Leach Date: Wed, 26 May 2021 18:01:44 +0100 Subject: [PATCH] sv.c: use Perl_sv_grow_fresh & Perl_sv_setvpn_fresh --- sv.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sv.c b/sv.c index c0f3208924cc..593dd4c4c0cc 100644 --- a/sv.c +++ b/sv.c @@ -5733,7 +5733,8 @@ Perl_newSV(pTHX_ const STRLEN len) new_SV(sv); if (len) { - sv_grow(sv, len + 1); + sv_upgrade(sv, SVt_PV); + sv_grow_fresh(sv, len + 1); } return sv; } @@ -9391,7 +9392,8 @@ Perl_newSVpvn_flags(pTHX_ const char *const s, const STRLEN len, const U32 flags And we're new code so I'm going to assert this from the start. */ assert(!(flags & ~(SVf_UTF8|SVs_TEMP))); new_SV(sv); - sv_setpvn(sv,s,len); + sv_upgrade(sv, SVt_PV); + sv_setpvn_fresh(sv,s,len); /* This code used to do a sv_2mortal(), however we now unroll the call to * sv_2mortal() and do what it does ourselves here. Since we have asserted @@ -9461,7 +9463,8 @@ Perl_newSVpv(pTHX_ const char *const s, const STRLEN len) SV *sv; new_SV(sv); - sv_setpvn(sv, s, len || s == NULL ? len : strlen(s)); + sv_upgrade(sv, SVt_PV); + sv_setpvn_fresh(sv, s, len || s == NULL ? len : strlen(s)); return sv; } @@ -9483,7 +9486,8 @@ Perl_newSVpvn(pTHX_ const char *const buffer, const STRLEN len) { SV *sv; new_SV(sv); - sv_setpvn(sv,buffer,len); + sv_upgrade(sv, SVt_PV); + sv_setpvn_fresh(sv,buffer,len); return sv; }