aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-09-13 11:38:33 +0100
committerNick Clifton <nickc@redhat.com>2023-09-13 11:38:33 +0100
commit452855278aa4789c5a7b87767e55de2c5a9938cf (patch)
tree8962086253fdd0b63f524d183ff5366022dd4f45
parentbc92a20a84ee4c458cd4d3e1dad0960f0349b07f (diff)
downloadgdb-452855278aa4789c5a7b87767e55de2c5a9938cf.zip
gdb-452855278aa4789c5a7b87767e55de2c5a9938cf.tar.gz
gdb-452855278aa4789c5a7b87767e55de2c5a9938cf.tar.bz2
Fix: "Possible Memory leak in bed hash.c"
* elf-strtab.c (_bfd_elf_strtab_init): In the event of memory allocation failure, make sure that the hash table is freed.
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/elf-strtab.c1
2 files changed, 6 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8b478cb..20dd6ba 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2023-09-13 Alan Modra <amodra@gmail.com>
+
+ * elf-strtab.c (_bfd_elf_strtab_init): In the event of memory
+ allocation failure, make sure that the hash table is freed.
+
2023-08-30 Tom Tromey <tom@tromey.com>
PR binutils/30703
diff --git a/bfd/elf-strtab.c b/bfd/elf-strtab.c
index 5de5af7..d52a307 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;
}