]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(_dl_close): Fix a memory leak.
authorUlrich Drepper <drepper@redhat.com>
Wed, 7 Oct 1998 18:24:14 +0000 (18:24 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 7 Oct 1998 18:24:14 +0000 (18:24 +0000)
Update _dl_global_scope[2] if the first object on the list is removed.

elf/dl-close.c

index ee35c6d5087c37c832aa85e12b865cf079121254..ab650bc7485526553fd11c9338bb2b862a6ae550 100644 (file)
@@ -117,11 +117,17 @@ _dl_close (struct link_map *map)
          if (imap->l_prev)
            imap->l_prev->l_next = imap->l_next;
          else
-           _dl_loaded = imap->l_next;
+           {
+             if (_dl_global_scope[2] == imap)
+               _dl_global_scope[2] = imap->l_next;
+             _dl_loaded = imap->l_next;
+           }
          if (imap->l_next)
            imap->l_next->l_prev = imap->l_prev;
          if (imap->l_searchlist && imap->l_searchlist != list)
            free (imap->l_searchlist);
+         free (imap->l_name);
+         free ((char *) imap->l_libname);
          free (imap);
        }
     }