summaryrefslogtreecommitdiff
path: root/locale.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2016-04-09 20:40:48 -0600
committerKarl Williamson <khw@cpan.org>2016-05-24 10:26:29 -0600
commit3c5f993ee8b2fd0912839a82e5d7d8c871a363ea (patch)
treec06f804d11335471e95a97a5956dabccdf95f4a4 /locale.c
parent4ebeff162503a0f3c404305458e4730ff29f1dea (diff)
downloadperl-3c5f993ee8b2fd0912839a82e5d7d8c871a363ea.tar.gz
locale.c: Free over-allocated space early
We may over malloc some space in buffers to strxfrm(). This frees it now instead of waiting for the whole block to be freed sometime later. This can be a significant amount of memory if the input string to strxfrm() is long.
Diffstat (limited to 'locale.c')
-rw-r--r--locale.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/locale.c b/locale.c
index 55e43b3c30..fd46a77566 100644
--- a/locale.c
+++ b/locale.c
@@ -1465,6 +1465,8 @@ Perl_mem_collxfrm(pTHX_ const char *input_string,
*xlen = xout - sizeof(PL_collation_ix);
+ /* Free up unneeded space; retain ehough for trailing NUL */
+ Renew(xbuf, xout + 1, char);
if (s != input_string) {
Safefree(s);