This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
remove leak in tr/ascii/utf8/
authorDavid Mitchell <davem@iabyn.com>
Tue, 12 Nov 2019 15:34:55 +0000 (15:34 +0000)
committerDavid Mitchell <davem@iabyn.com>
Tue, 12 Nov 2019 15:34:55 +0000 (15:34 +0000)
The recent change to use invlists left a bug in S_do_trans_invmap()
whereby it allocated a new temp buf if it knew the resulting string
would be too long, but failed to free the buffer at the end.

Showed up as smokes under ASAN failing these tests:

    op/tr_latin1.t
    op/tr.t
    uni/tr_utf8.t

doop.c

diff --git a/doop.c b/doop.c
index 6db986b..3e62c8c 100644 (file)
--- a/doop.c
+++ b/doop.c
@@ -523,6 +523,7 @@ S_do_trans_invmap(pTHX_ SV * const sv, AV * const invmap)
     s += s_len;
     if (! inplace) {
        sv_setpvn(sv, (char*)d0, d - d0);
+        Safefree(d0);
     }
     else {
        *d = '\0';