[binutils-gdb] Fix: "Possible Memory leak in bed hash.c"
Nick Clifton
nickc@sourceware.org
Wed Sep 13 10:39:11 GMT 2023
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=452855278aa4789c5a7b87767e55de2c5a9938cf
commit 452855278aa4789c5a7b87767e55de2c5a9938cf
Author: Alan Modra <amodra@gmail.com>
Date: Wed Sep 13 11:38:33 2023 +0100
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.
Diff:
---
bfd/ChangeLog | 5 +++++
bfd/elf-strtab.c | 1 +
2 files changed, 6 insertions(+)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8b478cbedcb..20dd6ba9e8e 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 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;
}
More information about the Binutils-cvs
mailing list