public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Florian Weimer <fw@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc] elf: Fix memory leak in _dl_find_object_update (bug 29062) Date: Wed, 13 Apr 2022 13:13:41 +0000 (GMT) [thread overview] Message-ID: <20220413131341.5FB98385741A@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4a41fc3cd9cea9223ea4f13f9c766a1e149a0ccc commit 4a41fc3cd9cea9223ea4f13f9c766a1e149a0ccc Author: Florian Weimer <fweimer@redhat.com> Date: Wed Apr 13 14:18:28 2022 +0200 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 5d28a8962dc ("elf: Add _dl_find_object function"). Diff: --- elf/dl-find_object.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/elf/dl-find_object.c b/elf/dl-find_object.c index 2b8df2fd67..4d5831b6f4 100644 --- a/elf/dl-find_object.c +++ b/elf/dl-find_object.c @@ -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) /* Skip proxy maps and already-processed maps. */ 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)); if (map_array == NULL) 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) map_array[i++] = l; } - if (count == 0) - return true; _dl_find_object_link_map_sort (map_array, count); bool ok = _dl_find_object_update_1 (map_array, count);
reply other threads:[~2022-04-13 13:13 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220413131341.5FB98385741A@sourceware.org \ --to=fw@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).