This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Fix PR15113 by using bfd_zmalloc to allocate hash table
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Sun, 10 Feb 2013 12:51:59 +1030
- Subject: Fix PR15113 by using bfd_zmalloc to allocate hash table
This PR is regarding uninitialized fields of elf_sh_link_hash_table.
The reporter also submitted a perfectly good fix, but this one should
prevent future problems.
PR ld/15113
* elf32-sh.c (sh_elf_link_hash_table_create): Use bfd_zmalloc.
Index: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.184
diff -u -p -r1.184 elf32-sh.c
--- bfd/elf32-sh.c 10 Jan 2013 20:03:53 -0000 1.184
+++ bfd/elf32-sh.c 9 Feb 2013 10:41:14 -0000
@@ -2549,7 +2549,7 @@ sh_elf_link_hash_table_create (bfd *abfd
struct elf_sh_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_sh_link_hash_table);
- ret = (struct elf_sh_link_hash_table *) bfd_malloc (amt);
+ ret = (struct elf_sh_link_hash_table *) bfd_zmalloc (amt);
if (ret == (struct elf_sh_link_hash_table *) NULL)
return NULL;
@@ -2562,17 +2562,6 @@ sh_elf_link_hash_table_create (bfd *abfd
return NULL;
}
- ret->sgot = NULL;
- ret->sgotplt = NULL;
- ret->srelgot = NULL;
- ret->splt = NULL;
- ret->srelplt = NULL;
- ret->sdynbss = NULL;
- ret->srelbss = NULL;
- ret->srelplt2 = NULL;
- ret->sym_cache.abfd = NULL;
- ret->tls_ldm_got.refcount = 0;
- ret->plt_info = NULL;
ret->vxworks_p = vxworks_object_p (abfd);
ret->fdpic_p = fdpic_object_p (abfd);
--
Alan Modra
Australia Development Lab, IBM