summaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-02-19 13:12:52 +1030
committerAlan Modra <amodra@gmail.com>2020-02-19 13:12:52 +1030
commit96d3b80f5498c0aa40099f37f6384f2041df045f (patch)
treeaf27c606e933b65af33c3fdd2e02cc6ef0dff8c3 /bfd/elf.c
parent986f078366b193ed9f5bd02af965f3af958ba859 (diff)
downloadbinutils-gdb-96d3b80f5498c0aa40099f37f6384f2041df045f.tar.gz
Check return status of memory alloc functions
This fixes a number of places that call a memory allocation function without checking for a NULL return before using. * mach-o.c (bfd_mach_o_flatten_sections): Return a bfd_boolean, FALSE if memory alloc fails. Adjust calls. * som.c (som_prep_for_fixups): Likewise. * vms-alpha.c (alpha_vms_add_fixup_lp, alpha_vms_add_fixup_ca), (alpha_vms_add_fixup_qr, alpha_vms_add_fixup_lr), (alpha_vms_add_lw_reloc, alpha_vms_add_qw_reloc): Likewise. * som.c (som_build_and_write_symbol_table): Return via error_return on seek failure. * vms-alpha.c (VEC_APPEND): Adjust for vector_grow1 changes. (VEC_APPEND_EL): Delete. (vector_grow1): Return pointer to element. Catch overflow. Return NULL on memory allocation failure. (alpha_vms_add_fixup_lp): Replace VEC_APPEND_EL with VEC_APPEND. (alpha_vms_add_fixup_ca): Likewise. (alpha_vms_link_add_object_symbols): Check VEC_APPEND result before using. * elf.c (bfd_section_from_shdr): Check bfd_zalloc2 result.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 2e045a7f255..31c89c9431a 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2071,6 +2071,8 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
{
sections_being_created = (bfd_boolean *)
bfd_zalloc2 (abfd, elf_numsections (abfd), sizeof (bfd_boolean));
+ if (sections_being_created == NULL)
+ return FALSE;
sections_being_created_abfd = abfd;
}
if (sections_being_created [shindex])