This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Suspected Memory leak in ld.so
- From: jiji vinitha <jiji dot vinitha at gmail dot com>
- To: libc-alpha at sourceware dot org
- Date: Fri, 2 Aug 2013 12:40:36 +0530
- Subject: Suspected Memory leak in ld.so
Hi,
There seems to be a memory leak in ld.so code in dl-deps.c. ( I am
using glibc-2.11.2. But this code is present in current glibc version
also)
The code snippet is given below
…
/* Maybe we can remove some relocation dependencies now. */
assert (map->l_searchlist.r_list[0] == map);
struct link_map_reldeps *l_reldeps = NULL;
if (map->l_reldeps != NULL)
{
for (i = 1; i < nlist; ++i)
map->l_searchlist.r_list[i]->l_reserved = 1;
struct link_map **list = &map->l_reldeps->list[0];
for (i = 0; i < map->l_reldeps->act; ++i)
if (list[i]->l_reserved)
{
/* Need to allocate new array of relocation dependencies. */
struct link_map_reldeps *l_reldeps;
l_reldeps = malloc (sizeof (*l_reldeps) ==> HERE
+ map->l_reldepsmax
* sizeof (struct link_map *));
if (l_reldeps == NULL)
/* Bad luck, keep the reldeps duplicated between
map->l_reldeps->list and map->l_initfini lists. */
;
…
It looks the malloc() in the above code might leak memory. ( Because
of the duplicate declaration struct link_map_reldeps *l_reldeps;
inside the if {} ).
Regards,
Vinitha