This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/19039] argp leaks memory when argp.options is a non-NULL array of zero length
- From: "kstauffer at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 01 Oct 2015 00:57:17 +0000
- Subject: [Bug libc/19039] argp leaks memory when argp.options is a non-NULL array of zero length
- Auto-submitted: auto-generated
- References: <bug-19039-131 at http dot sourceware dot org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=19039
--- Comment #1 from Kenny Stauffer <kstauffer at gmail dot com> ---
The leaked memory is allocated here:
argp-help.c:make_hol
hol->entries = malloc (sizeof (struct hol_entry) * hol->num_entries);
hol->short_options = malloc (num_short_options + 1);
When argp.options points to an array of zero length, num_entries is 0.
The leak happens here:
argp-help.c:hol_free
if (hol->num_entries > 0)
{
free (hol->entries);
free (hol->short_options);
}
Of the many ways to fix this, perhaps the easiest would be to change make_hol
from this:
opts = argp.options;
...
if (opts)
To this:
opts = argp.options;
...
if (opts && ! oend (opts))
--
You are receiving this mail because:
You are on the CC list for the bug.