summaryrefslogtreecommitdiff
path: root/locale.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2019-04-16 15:48:39 +0100
committerDavid Mitchell <davem@iabyn.com>2019-04-16 16:15:56 +0100
commit2bfe2a2773c59588ac2bf11b5d9439c92d86fb62 (patch)
treedbe83fc5df4efe29f253a262c09ca1343751f0da /locale.c
parent44955e7de88913c476b06c9046ed65775b693da7 (diff)
downloadperl-2bfe2a2773c59588ac2bf11b5d9439c92d86fb62.tar.gz
fix locale leaks on utf8 strings
For example the following leaked: require POSIX; import POSIX ':locale_h'; setlocale(&POSIX::LC_ALL, 'aa_DJ.iso88591') or die; use locale; my $ok = 'A' lt chr 0x100; Some code in Perl__mem_collxfrm() does a couple of for (j = 1; j < 256; j++) { ... } loops where for each chr(j) character it recursively calls itself, and records the index of the 'smallest' / 'largest' result. However, when updating cur_min_x / cur_max_x, it wasn't freeing the previous value. The symptoms were that valgrind / Address Sanitizer found fault with lib/locale.t
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 81aa00e33f..8a1ddc2c20 100644
--- a/locale.c
+++ b/locale.c
@@ -3951,6 +3951,7 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
cur_min_x + COLLXFRM_HDR_LEN))
{
PL_strxfrm_NUL_replacement = j;
+ safefree(cur_min_x);
cur_min_x = x;
}
else {
@@ -4106,6 +4107,7 @@ Perl__mem_collxfrm(pTHX_ const char *input_string,
cur_max_x + COLLXFRM_HDR_LEN))
{
PL_strxfrm_max_cp = j;
+ safefree(cur_max_x);
cur_max_x = x;
}
else {