diff --git a/sv.c b/sv.c index 06c0b8399fec..ac1d972fe2a9 100644 --- a/sv.c +++ b/sv.c @@ -1574,14 +1574,19 @@ Perl_sv_grow(pTHX_ SV *const sv, STRLEN newlen) newlen++; #endif +#if defined(PERL_USE_MALLOC_SIZE) && defined(Perl_safesysmalloc_size) +#define PERL_UNWARANTED_CHUMMINESS_WITH_MALLOC +#endif + if (newlen > SvLEN(sv)) { /* need more room? */ STRLEN minlen = SvCUR(sv); minlen += (minlen >> PERL_STRLEN_EXPAND_SHIFT) + 10; if (newlen < minlen) newlen = minlen; -#ifndef Perl_safesysmalloc_size - if (SvLEN(sv)) +#ifndef PERL_UNWARANTED_CHUMMINESS_WITH_MALLOC + if (SvLEN(sv)) { newlen = PERL_STRLEN_ROUNDUP(newlen); + } #endif if (SvLEN(sv) && s) { s = (char*)saferealloc(s, newlen); @@ -1593,7 +1598,7 @@ Perl_sv_grow(pTHX_ SV *const sv, STRLEN newlen) } } SvPV_set(sv, s); -#ifdef Perl_safesysmalloc_size +#ifdef PERL_UNWARANTED_CHUMMINESS_WITH_MALLOC /* Do this here, do it once, do it right, and then we will never get called back into sv_grow() unless there really is some growing needed. */