From 2600d80ccd04666f28608364be74d7ee552977ae Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 23 Aug 2019 19:16:25 +0930 Subject: [PATCH] PR24933, Memory leak in elf_x86_64_get_synthetic_symtab PR 24933 * elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Don't exit on error without freeing plts[] contents. --- bfd/ChangeLog | 6 ++++++ bfd/elfxx-x86.c | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 0eb514d314c..b39acb19b21 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2019-08-23 Alan Modra + + PR 24933 + * elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Don't exit + on error without freeing plts[] contents. + 2019-08-22 Dennis Zhang * cpu-arm.c: New entries for Cortex-M35P, Cortex-A77, Cortex-A76AE. diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index 78ed41ad381..634f911ca53 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -2171,17 +2171,18 @@ _bfd_x86_elf_get_synthetic_symtab (bfd *abfd, bfd_vma); bfd_boolean (*valid_plt_reloc_p) (unsigned int); + dynrelbuf = NULL; if (count == 0) - return -1; + goto bad_return; dynrelbuf = (arelent **) bfd_malloc (relsize); if (dynrelbuf == NULL) - return -1; + goto bad_return; dynrelcount = bfd_canonicalize_dynamic_reloc (abfd, dynrelbuf, dynsyms); if (dynrelcount <= 0) - return -1; + goto bad_return; /* Sort the relocs by address. */ qsort (dynrelbuf, dynrelcount, sizeof (arelent *), -- 2.30.2