diff options
author | Alan Modra <amodra@gmail.com> | 2008-08-08 08:00:14 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2008-08-08 08:00:14 +0000 |
commit | 4dd07732f266b95c1ddec864b415ff2f41e52212 (patch) | |
tree | 4243f5e2c8db81aad8ef42f59677c0029176a1c8 /bfd/elf.c | |
parent | c3c3645668dd98baba51d2877c901c33a60b9f31 (diff) | |
download | gdb-4dd07732f266b95c1ddec864b415ff2f41e52212.zip gdb-4dd07732f266b95c1ddec864b415ff2f41e52212.tar.gz gdb-4dd07732f266b95c1ddec864b415ff2f41e52212.tar.bz2 |
* elf.c (bfd_elf_get_elf_syms): Don't leak memory on error.
* elflink.c (_bfd_elf_link_read_relocs): bfd_release on error.
(elf_link_add_object_symbols): Don't leak memory on error.
(bfd_elf_size_dynsym_hash_dynstr): Likewise.
(elf_fixup_link_order): Free sections.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -358,6 +358,7 @@ bfd_elf_get_elf_syms (bfd *ibfd, const bfd_byte *esym; Elf_External_Sym_Shndx *alloc_extshndx; Elf_External_Sym_Shndx *shndx; + Elf_Internal_Sym *alloc_intsym; Elf_Internal_Sym *isym; Elf_Internal_Sym *isymend; const struct elf_backend_data *bed; @@ -379,6 +380,7 @@ bfd_elf_get_elf_syms (bfd *ibfd, /* Read the symbols. */ alloc_ext = NULL; alloc_extshndx = NULL; + alloc_intsym = NULL; bed = get_elf_backend_data (ibfd); extsym_size = bed->s->sizeof_sym; amt = symcount * extsym_size; @@ -419,7 +421,8 @@ bfd_elf_get_elf_syms (bfd *ibfd, if (intsym_buf == NULL) { - intsym_buf = bfd_malloc2 (symcount, sizeof (Elf_Internal_Sym)); + alloc_intsym = bfd_malloc2 (symcount, sizeof (Elf_Internal_Sym)); + intsym_buf = alloc_intsym; if (intsym_buf == NULL) goto out; } @@ -435,6 +438,8 @@ bfd_elf_get_elf_syms (bfd *ibfd, (*_bfd_error_handler) (_("%B symbol number %lu references " "nonexistent SHT_SYMTAB_SHNDX section"), ibfd, (unsigned long) symoffset); + if (alloc_intsym != NULL) + free (alloc_intsym); intsym_buf = NULL; goto out; } |