summaryrefslogtreecommitdiff
path: root/elf/dl-open.c
diff options
context:
space:
mode:
Diffstat (limited to 'elf/dl-open.c')
-rw-r--r--elf/dl-open.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 583878781e..0afe94b5bf 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -125,14 +125,18 @@ add_to_global (struct link_map *new)
{
/* We have to extend the existing array of link maps in the
main map. */
+ size_t new_size = ns->_ns_global_scope_alloc;
+ if (new_size >= 256 && new_size > to_add + 8)
+ new_size *= 2;
+ else
+ new_size += to_add + 8;
new_global = (struct link_map **)
realloc (ns->_ns_main_searchlist->r_list,
- ((ns->_ns_global_scope_alloc + to_add + 8)
- * sizeof (struct link_map *)));
+ new_size * sizeof (struct link_map *));
if (new_global == NULL)
goto nomem;
- ns->_ns_global_scope_alloc += to_add + 8;
+ ns->_ns_global_scope_alloc = new_size;
ns->_ns_main_searchlist->r_list = new_global;
}