[binutils-gdb] asan: leak in bfd_section_from_shdr
Alan Modra
amodra@sourceware.org
Tue Nov 3 00:05:24 GMT 2020
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=706d7ce94809f3d647450eb54e2e77e4732bd9af
commit 706d7ce94809f3d647450eb54e2e77e4732bd9af
Author: Alan Modra <amodra@gmail.com>
Date: Tue Nov 3 10:23:03 2020 +1030
asan: leak in bfd_section_from_shdr
* elf.c (bfd_section_from_shdr): Free sections_being_created.
Use bfd_zmalloc.
Diff:
---
bfd/ChangeLog | 5 +++++
bfd/elf.c | 8 +++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e632282a71c..94c8e3b3b58 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2020-11-03 Alan Modra <amodra@gmail.com>
+
+ * elf.c (bfd_section_from_shdr): Free sections_being_created.
+ Use bfd_zmalloc.
+
2020-11-02 Alan Modra <amodra@gmail.com>
PR 15146
diff --git a/bfd/elf.c b/bfd/elf.c
index 549f661b9d8..3163d34e8d5 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])
More information about the Binutils-cvs
mailing list