This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix locale leaks on utf8 strings
authorDavid Mitchell <davem@iabyn.com>
Tue, 16 Apr 2019 14:48:39 +0000 (15:48 +0100)
committerDavid Mitchell <davem@iabyn.com>
Tue, 16 Apr 2019 15:15:56 +0000 (16:15 +0100)
commit2bfe2a2773c59588ac2bf11b5d9439c92d86fb62
treedbe83fc5df4efe29f253a262c09ca1343751f0da
parent44955e7de88913c476b06c9046ed65775b693da7
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
locale.c