This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]