aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-arm.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2008-02-20 17:42:36 +0000
committerNick Clifton <nickc@redhat.com>2008-02-20 17:42:36 +0000
commit515ef31dec50185cc5d8a6f88b51832bfd259e87 (patch)
tree3b25393193afaf4f670cf6da64ff323faee10203 /bfd/elf32-arm.c
parent4443cd0f6e76d3ecb793814445d2e01b41f29fbe (diff)
downloadgdb-515ef31dec50185cc5d8a6f88b51832bfd259e87.zip
gdb-515ef31dec50185cc5d8a6f88b51832bfd259e87.tar.gz
gdb-515ef31dec50185cc5d8a6f88b51832bfd259e87.tar.bz2
PR 868
* libbfd.c (bfd_realloc_or_free): New function. Performs like bfd_realloc, but if the (re)allocation fails, the pointer is freed. * libbfd-in.h: Prototype. * libbfd.h: Regenerate. * bfdio.c (bfd_bwrite): Use the new function. (bfd_seek): Likewise. * bfdwin.c:(bfd_get_file_window): Likewise. * elf-strtab.c (_bfd_elf_strtab_add): Likewise. * elf32-ppc.c (ppc_elf_relax_section): Likewise. * elf32-xtensa.c (vsprintf_msg): Likewise. * mach-o.c (bfd_mach_o_core_fetch_environment): Likewise. * stabs.c (_bfd_link_seciton_stabs): Likewise. * vms-misc.c (_bfd_vms_get_record): Likewise. * vms-tir.c (check_section): Likewise. * vms.c (vms_new_section_hook): Likewise. * elf32-arm.c (elf32_arm_section_map_add): Check that the allocation of sec_data->map succeeded before using it. * elflink.c (elf_link_output_sym): Do not overwrite finfo-> symshndxbuf until it is known that the reallocation succeeded.
Diffstat (limited to 'bfd/elf32-arm.c')
-rw-r--r--bfd/elf32-arm.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 7218ba8..6f66a715 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -2948,12 +2948,15 @@ elf32_arm_section_map_add (asection *sec, char type, bfd_vma vma)
if (sec_data->mapcount > sec_data->mapsize)
{
sec_data->mapsize *= 2;
- sec_data->map = bfd_realloc (sec_data->map, sec_data->mapsize
- * sizeof (elf32_arm_section_map));
+ sec_data->map = bfd_realloc_or_free (sec_data->map, sec_data->mapsize
+ * sizeof (elf32_arm_section_map));
+ }
+
+ if (sec_data->map)
+ {
+ sec_data->map[newidx].vma = vma;
+ sec_data->map[newidx].type = type;
}
-
- sec_data->map[newidx].vma = vma;
- sec_data->map[newidx].type = type;
}