GNU bug report logs -
#19578
Memory leaks in coreutils/lib/locale_charset.c
Previous Next
Reported by: Zhaopeng Li <zpli <at> ustc.edu.cn>
Date: Tue, 13 Jan 2015 05:49:02 UTC
Severity: normal
Tags: notabug
Merged with 19580
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 13/01/15 04:06, Zhaopeng Li wrote:
> Platform: Ubuntu 14.10 64-bit
> Coreutils Version 8.23
>
>
>
> At line 534 of coreutils/lib/locale_charset.c, var ‘aliases' points to a buffer which is allocated using malloc() .
>
> This buffer is not freed when codeset is still an empty string after the loop (Line 534~542).
>
> So it will be leaked under such situation.
>
>
>
> Line 533 /* Resolve alias. */
> Line 534 for (aliases = get_charset_aliases ();
> *aliases != '\0';
> aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
> if (strcmp (codeset, aliases) == 0
> || (aliases[0] == '*' && aliases[1] == '\0'))
> {
> codeset = aliases + strlen (aliases) + 1;
> break;
> }
>
> /* Don't return an empty string. GNU libc and GNU libiconv interpret
> the empty string as denoting "the locale's character encoding",
> thus GNU libiconv would call this function a second time. */
> if (codeset[0] == '\0')
> codeset = "ASCII";
What reports this leak?
Note that file name is not present in coreutils?
The code you're referring to is:
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/localcharset.c;h=b4af28cd#l588
Though aliases is never freed here, nor should it be.
What am I missing?
thanks,
Pádraig
This bug report was last modified 10 years and 137 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.