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/pef.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/pef.c')
-rw-r--r-- | bfd/pef.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -221,15 +221,16 @@ bfd_pef_print_symbol (bfd *abfd, fprintf (file, " %-5s %s", symbol->section->name, symbol->name); if (CONST_STRNEQ (symbol->name, "__traceback_")) { - unsigned char *buf = xmalloc (symbol->udata.i); + unsigned char *buf; size_t offset = symbol->value + 4; size_t len = symbol->udata.i; - int ret; - bfd_get_section_contents (abfd, symbol->section, buf, offset, len); - ret = bfd_pef_parse_traceback_table (abfd, symbol->section, buf, - len, 0, NULL, file); - if (ret < 0) + buf = bfd_malloc (len); + if (buf == NULL + || !bfd_get_section_contents (abfd, symbol->section, buf, + offset, len) + || bfd_pef_parse_traceback_table (abfd, symbol->section, buf, + len, 0, NULL, file) < 0) fprintf (file, " [ERROR]"); free (buf); } |