diff options
author | David Mitchell <davem@iabyn.com> | 2019-04-16 15:48:39 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2019-04-16 16:15:56 +0100 |
commit | 2bfe2a2773c59588ac2bf11b5d9439c92d86fb62 (patch) | |
tree | dbe83fc5df4efe29f253a262c09ca1343751f0da /locale.c | |
parent | 44955e7de88913c476b06c9046ed65775b693da7 (diff) | |
download | perl-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.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -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 { |