PR24933, Memory leak in elf_x86_64_get_synthetic_symtab

Alan Modra amodra@gmail.com
Fri Aug 23 10:01:00 GMT 2019


	PR 24933
	* elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Don't exit
	on error without freeing plts[] contents.

diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index 78ed41ad38..634f911ca5 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 *),

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list