Skip to content

Commit fe1c169

Browse files
maukethibaultduponchelle
authored andcommitted
sv.c: fix crash with newSVpvf("")
Fixes #23393.
1 parent d311b4d commit fe1c169

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

sv.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10004,13 +10004,12 @@ Perl_newSVpvf(pTHX_ const char *const pat, ...)
1000410004
SV *
1000510005
Perl_vnewSVpvf(pTHX_ const char *const pat, va_list *const args)
1000610006
{
10007-
SV *sv;
10008-
1000910007
PERL_ARGS_ASSERT_VNEWSVPVF;
1001010008

1001110009
STRLEN patlen = strlen(pat);
1001210010

10013-
sv = newSV(patlen);
10011+
/* newSV(0) would allocate a blank bodyless SV */
10012+
SV *sv = newSV(patlen ? patlen : 1);
1001410013
SvPVCLEAR_FRESH(sv);
1001510014
sv_vcatpvfn_flags(sv, pat, patlen, args, NULL, 0, NULL, 0);
1001610015
return sv;

0 commit comments

Comments
 (0)