diff options
author | Alan Modra <amodra@gmail.com> | 2019-10-14 13:34:30 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-10-14 16:47:12 +1030 |
commit | ec9bd0a22dd42327ae9943937a96f1e865fb5d46 (patch) | |
tree | a9f88543988ee484b7db067816ae25e00b431c89 /bfd/som.c | |
parent | 03f04b53b24fac848328eeafbea589d1120ccce0 (diff) | |
download | gdb-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/som.c')
-rw-r--r-- | bfd/som.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -3309,13 +3309,16 @@ som_write_space_strings (bfd *abfd, /* Chunk of memory that we can use as buffer space, then throw away. */ size_t tmp_space_size = SOM_TMP_BUFSIZE; - char *tmp_space = xmalloc (tmp_space_size); + char *tmp_space = bfd_malloc (tmp_space_size); char *p = tmp_space; unsigned int strings_size = 0; asection *section; bfd_size_type amt; bfd_size_type res; + if (tmp_space == NULL) + return FALSE; + /* Seek to the start of the space strings in preparation for writing them out. */ if (bfd_seek (abfd, (file_ptr) current_offset, SEEK_SET) != 0) @@ -3419,12 +3422,15 @@ som_write_symbol_strings (bfd *abfd, /* Chunk of memory that we can use as buffer space, then throw away. */ size_t tmp_space_size = SOM_TMP_BUFSIZE; - char *tmp_space = xmalloc (tmp_space_size); + char *tmp_space = bfd_malloc (tmp_space_size); char *p = tmp_space; unsigned int strings_size = 0; bfd_size_type amt; bfd_size_type res; + if (tmp_space == NULL) + return FALSE; + /* This gets a bit gruesome because of the compilation unit. The strings within the compilation unit are part of the symbol strings, but don't have symbol_dictionary entries. So, manually |