]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
output_section_statement leak
authorAlan Modra <amodra@gmail.com>
Sat, 11 Jan 2025 05:30:55 +0000 (16:00 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 16 Jan 2025 22:00:11 +0000 (08:30 +1030)
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.

ld/ldemul.c

index ce243143f8ec99fb2fe469ff30c032626f686b67..0f3cb1a01255f3300ca2a92b3633d9a9002fcee2 100644 (file)
@@ -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);
 }