aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-11-03 10:23:03 +1030
committerAlan Modra <amodra@gmail.com>2020-11-03 10:34:51 +1030
commit706d7ce94809f3d647450eb54e2e77e4732bd9af (patch)
treed95ae3e2f941e0d4884a6038eabb7df9cb9b7780 /bfd/elf.c
parentaf61e84fd2d6eca1273f1d24b8d7b89c5a1441e5 (diff)
downloadgdb-706d7ce94809f3d647450eb54e2e77e4732bd9af.zip
gdb-706d7ce94809f3d647450eb54e2e77e4732bd9af.tar.gz
gdb-706d7ce94809f3d647450eb54e2e77e4732bd9af.tar.bz2
asan: leak in bfd_section_from_shdr
* elf.c (bfd_section_from_shdr): Free sections_being_created. Use bfd_zmalloc.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 549f661..3163d34 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2061,17 +2061,19 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
rather than being held in a static pointer. */
if (sections_being_created_abfd != abfd)
- sections_being_created = NULL;
+ {
+ free (sections_being_created);
+ sections_being_created = NULL;
+ }
if (sections_being_created == NULL)
{
size_t amt = elf_numsections (abfd) * sizeof (bfd_boolean);
/* PR 26005: Do not use bfd_zalloc here as the memory might
be released before the bfd has been fully scanned. */
- sections_being_created = (bfd_boolean *) bfd_malloc (amt);
+ sections_being_created = (bfd_boolean *) bfd_zmalloc (amt);
if (sections_being_created == NULL)
return FALSE;
- memset (sections_being_created, FALSE, amt);
sections_being_created_abfd = abfd;
}
if (sections_being_created [shindex])