From c785932bb5ae8f8b9e8857c6436e13f051710858 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 20 Jan 2025 11:33:49 +1030 Subject: [PATCH] Re: elflink.c memory leaks * elflink.c (elf_link_add_object_symbols): Free old_strtab in another code path. Revert one unnecessary change in last patch. --- bfd/elflink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bfd/elflink.c b/bfd/elflink.c index 8974015728d..27b02dd404f 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -5807,6 +5807,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) return true; } + free (old_strtab); + old_strtab = NULL; if (old_tab != NULL) { if (!(*bed->notice_as_needed) (abfd, info, notice_needed)) @@ -6030,7 +6032,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) if (bed->check_directives && !(*bed->check_directives) (abfd, info)) - goto error_free_vers; + goto error_return; /* If this is a non-traditional link, try to optimize the handling of the .stab/.stabstr sections. */ -- 2.39.5