mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-23 03:29:47 +08:00
asan: leak in bfd_section_from_shdr
* elf.c (bfd_section_from_shdr): Free sections_being_created. Use bfd_zmalloc.
This commit is contained in:
@ -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>
|
2020-11-02 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
PR 15146
|
PR 15146
|
||||||
|
@ -2061,17 +2061,19 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
|||||||
rather than being held in a static pointer. */
|
rather than being held in a static pointer. */
|
||||||
|
|
||||||
if (sections_being_created_abfd != abfd)
|
if (sections_being_created_abfd != abfd)
|
||||||
sections_being_created = NULL;
|
{
|
||||||
|
free (sections_being_created);
|
||||||
|
sections_being_created = NULL;
|
||||||
|
}
|
||||||
if (sections_being_created == NULL)
|
if (sections_being_created == NULL)
|
||||||
{
|
{
|
||||||
size_t amt = elf_numsections (abfd) * sizeof (bfd_boolean);
|
size_t amt = elf_numsections (abfd) * sizeof (bfd_boolean);
|
||||||
|
|
||||||
/* PR 26005: Do not use bfd_zalloc here as the memory might
|
/* PR 26005: Do not use bfd_zalloc here as the memory might
|
||||||
be released before the bfd has been fully scanned. */
|
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)
|
if (sections_being_created == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
memset (sections_being_created, FALSE, amt);
|
|
||||||
sections_being_created_abfd = abfd;
|
sections_being_created_abfd = abfd;
|
||||||
}
|
}
|
||||||
if (sections_being_created [shindex])
|
if (sections_being_created [shindex])
|
||||||
|
Reference in New Issue
Block a user