summaryrefslogtreecommitdiff
path: root/elf/dl-close.c
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@redhat.com>2011-02-25 20:49:48 -0500
committerUlrich Drepper <drepper@gmail.com>2011-02-25 20:49:48 -0500
commit4bff6e0175ed195871f4e01cc4c4c33274b8f6e3 (patch)
treec66f1fa828edf1592d7f73c4200c16ae2996f8b5 /elf/dl-close.c
parent661b9e2014b3964469198ce7697a1d0d06aa4882 (diff)
Fix memory leak in dlopen with RTLD_NOLOAD.
Diffstat (limited to 'elf/dl-close.c')
-rw-r--r--elf/dl-close.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/elf/dl-close.c b/elf/dl-close.c
index f6d8dd313c..efb2b584f2 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -1,5 +1,5 @@
/* Close a shared object opened by `_dl_open'.
- Copyright (C) 1996-2007, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1996-2007, 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -119,8 +119,17 @@ _dl_close_worker (struct link_map *map)
if (map->l_direct_opencount > 0 || map->l_type != lt_loaded
|| dl_close_state != not_pending)
{
- if (map->l_direct_opencount == 0 && map->l_type == lt_loaded)
- dl_close_state = rerun;
+ if (map->l_direct_opencount == 0)
+ {
+ if (map->l_type == lt_loaded)
+ dl_close_state = rerun;
+ else if (map->l_type == lt_library)
+ {
+ struct link_map **oldp = map->l_initfini;
+ map->l_initfini = map->l_orig_initfini;
+ _dl_scope_free (oldp);
+ }
+ }
/* There are still references to this object. Do nothing more. */
if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0))