aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-10-14 13:34:30 +1030
committerAlan Modra <amodra@gmail.com>2019-10-14 16:47:12 +1030
commitec9bd0a22dd42327ae9943937a96f1e865fb5d46 (patch)
treea9f88543988ee484b7db067816ae25e00b431c89 /bfd/elflink.c
parent03f04b53b24fac848328eeafbea589d1120ccce0 (diff)
downloadgdb-ec9bd0a22dd42327ae9943937a96f1e865fb5d46.zip
gdb-ec9bd0a22dd42327ae9943937a96f1e865fb5d46.tar.gz
gdb-ec9bd0a22dd42327ae9943937a96f1e865fb5d46.tar.bz2
PR24955, libbfd terminating program on out of memory (part2)
PR 24955 * elflink.c (elf_output_implib): Don't use xmalloc. Don't ignore return value of bfd_alloc2. * peXXigen.c (_bfd_XXi_write_codeview_record): Don't use xmalloc. * pef.c (bfd_pef_print_symbol): Likewise. Don't ignore return value of bfd_get_section_contents. * som.c (som_write_space_strings): Don't use xmalloc. (som_write_symbol_strings): Likewise.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 395d96d..d0f70cb 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -11649,7 +11649,10 @@ elf_output_implib (bfd *abfd, struct bfd_link_info *info)
return FALSE;
/* Read in the symbol table. */
- sympp = (asymbol **) xmalloc (symsize);
+ sympp = (asymbol **) bfd_malloc (symsize);
+ if (sympp == NULL)
+ return FALSE;
+
symcount = bfd_canonicalize_symtab (abfd, sympp);
if (symcount < 0)
goto free_sym_buf;
@@ -11677,6 +11680,9 @@ elf_output_implib (bfd *abfd, struct bfd_link_info *info)
/* Make symbols absolute. */
osymbuf = (elf_symbol_type *) bfd_alloc2 (implib_bfd, symcount,
sizeof (*osymbuf));
+ if (osymbuf == NULL)
+ goto free_sym_buf;
+
for (src_count = 0; src_count < symcount; src_count++)
{
memcpy (&osymbuf[src_count], (elf_symbol_type *) sympp[src_count],