From 452855278aa4789c5a7b87767e55de2c5a9938cf Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 13 Sep 2023 11:38:33 +0100 Subject: [PATCH] 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. --- 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 + + * 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 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; } -- 2.30.2