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.
This commit is contained in:
Alan Modra
2019-10-14 13:34:30 +10:30
parent 03f04b53b2
commit ec9bd0a22d
5 changed files with 37 additions and 10 deletions

View File

@@ -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],