mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-10 05:03:06 +03:00
elf: Fix memory leak in _dl_find_object_update (bug 29062)
The count can be zero if an object has already been loaded as
an indirect dependency (so that l_searchlist.r_list in its link
map is still NULL) is promoted to global scope via RTLD_GLOBAL.
Fixes commit 5d28a8962d
("elf: Add _dl_find_object function").
This commit is contained in:
@@ -788,6 +788,9 @@ _dl_find_object_update (struct link_map *new_map)
|
|||||||
for (struct link_map *l = new_map; l != NULL; l = l->l_next)
|
for (struct link_map *l = new_map; l != NULL; l = l->l_next)
|
||||||
/* Skip proxy maps and already-processed maps. */
|
/* Skip proxy maps and already-processed maps. */
|
||||||
count += l == l->l_real && !l->l_find_object_processed;
|
count += l == l->l_real && !l->l_find_object_processed;
|
||||||
|
if (count == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
struct link_map **map_array = malloc (count * sizeof (*map_array));
|
struct link_map **map_array = malloc (count * sizeof (*map_array));
|
||||||
if (map_array == NULL)
|
if (map_array == NULL)
|
||||||
return false;
|
return false;
|
||||||
@@ -797,8 +800,6 @@ _dl_find_object_update (struct link_map *new_map)
|
|||||||
if (l == l->l_real && !l->l_find_object_processed)
|
if (l == l->l_real && !l->l_find_object_processed)
|
||||||
map_array[i++] = l;
|
map_array[i++] = l;
|
||||||
}
|
}
|
||||||
if (count == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
_dl_find_object_link_map_sort (map_array, count);
|
_dl_find_object_link_map_sort (map_array, count);
|
||||||
bool ok = _dl_find_object_update_1 (map_array, count);
|
bool ok = _dl_find_object_update_1 (map_array, count);
|
||||||
|
Reference in New Issue
Block a user