[binutils-gdb] Re: elflink.c memory leaks

Alan Modra amodra@sourceware.org
Mon Jan 20 07:55:25 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c785932bb5ae8f8b9e8857c6436e13f051710858

commit c785932bb5ae8f8b9e8857c6436e13f051710858
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Jan 20 11:33:49 2025 +1030

    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.

Diff:
---
 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.  */


More information about the Binutils-cvs mailing list