Re: objcopy write_debugging_info memory leaks
authorAlan Modra <amodra@gmail.com>
Thu, 6 Apr 2023 11:55:22 +0000 (21:25 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 6 Apr 2023 11:57:54 +0000 (21:27 +0930)
Oops, tried to free too much

* wrstabs.c (write_stabs_in_sections_debugging_info): Don't
free strings.

binutils/wrstabs.c

index b676374558b184d2fdf36e9862f7e63f1ec75ed9..234a96f98a3a03f956033e202b36cf362a88afbd 100644 (file)
@@ -464,7 +464,7 @@ write_stabs_in_sections_debugging_info (bfd *abfd, void *dhandle,
                                        bfd_size_type *pstringsize)
 {
   struct stab_write_handle info;
-  struct string_hash_entry *h, *hnext;
+  struct string_hash_entry *h;
   bfd_byte *p;
   bool ret;
 
@@ -535,11 +535,6 @@ write_stabs_in_sections_debugging_info (bfd *abfd, void *dhandle,
   free (info.symbols);
   ret = false;
  out:
-  for (h = info.strings; h != NULL; h = hnext)
-    {
-      hnext = h->next;
-      free (h);
-    }
   while (info.type_stack != NULL)
     {
       struct stab_type_stack *s = info.type_stack;