aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--elf/dl-close.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/elf/dl-close.c b/elf/dl-close.c
index 104c299209..73b2817bbf 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -756,6 +756,10 @@ _dl_close_worker (struct link_map *map, bool force)
if (imap->l_runpath_dirs.dirs != (void *) -1)
free (imap->l_runpath_dirs.dirs);
+ /* Clear GL(dl_initfirst) when freeing its link_map memory. */
+ if (imap == GL(dl_initfirst))
+ GL(dl_initfirst) = NULL;
+
free (imap);
}
}