Possible Memory leak in bed hash.c

Alan Modra amodra@gmail.com
Wed Sep 13 06:37:46 GMT 2023


On Tue, Sep 12, 2023 at 02:05:29PM +0200, jacob navia wrote:
> Just call « bfd_hash_table_free » instead of « free » 

Not quite.  We should add a call

            * elf-strtab.c (_bfd_elf_strtab_init): Call bfd_hash_table_free
            on error return path.

diff --git a/bfd/elf-strtab.c b/bfd/elf-strtab.c
index 5de5af73bb4..d52a3079f4c 100644
--- a/bfd/elf-strtab.c
+++ b/bfd/elf-strtab.c
@@ -116,6 +116,7 @@ _bfd_elf_strtab_init (void)
 		  bfd_malloc (table->alloced * amt));
   if (table->array == NULL)
     {
+      bfd_hash_table_free (&table->table);
       free (table);
       return NULL;
     }

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list