[binutils-gdb] output_section_statement leak

Alan Modra amodra@sourceware.org
Thu Jan 16 22:08:07 GMT 2025


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

commit 566c131c6687b5c70398bda016c8f070ba172595
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Jan 11 16:00:55 2025 +1030

    output_section_statement leak
    
    This frees output_section_statement data, which is currently only used
    by elf targets but doing so for all targets is simpler and more
    future proof than adding ths to ldelf_finish.  (Doing it there
    requires moving the function to ldelfgen.c.)
    
            * ldemul.c (finish_default): Free os->data.

Diff:
---
 ld/ldemul.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ld/ldemul.c b/ld/ldemul.c
index ce243143f8e..0f3cb1a0125 100644
--- a/ld/ldemul.c
+++ b/ld/ldemul.c
@@ -299,6 +299,12 @@ before_allocation_default (void)
 void
 finish_default (void)
 {
+  lang_output_section_statement_type *os;
+  for (os = (void *) lang_os_list.head; os != NULL; os = os->next)
+    {
+      free (os->data);
+      os->data = NULL;
+    }
   if (!bfd_link_relocatable (&link_info))
     _bfd_fix_excluded_sec_syms (link_info.output_bfd, &link_info);
 }


More information about the Binutils-cvs mailing list