Skip to content

Commit

Permalink
locale.c: Free over-allocated space early
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
khwilliamson committed May 24, 2016
1 parent 4ebeff1 commit 3c5f993
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions locale.c
Expand Up @@ -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);
Expand Down

0 comments on commit 3c5f993

Please sign in to comment.