diff options
author | Alan Modra <amodra@gmail.com> | 2017-07-01 21:58:10 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2017-07-02 08:33:12 +0930 |
commit | bae7501e87ab614115d9d3213b4dd18d96e604db (patch) | |
tree | e0b4a01a423eb5d078903002b6a0223e575069cd /binutils/nlmconv.c | |
parent | 25c5412713badef8cf779186174200ecd880b329 (diff) | |
download | gdb-bae7501e87ab614115d9d3213b4dd18d96e604db.zip gdb-bae7501e87ab614115d9d3213b4dd18d96e604db.tar.gz gdb-bae7501e87ab614115d9d3213b4dd18d96e604db.tar.bz2 |
Use bfd_malloc_and_get_section
It's nicer than xmalloc followed by bfd_get_section_contents, since
xmalloc exits on failure and needs a check that its size_t arg doesn't
lose high bits when converted from bfd_size_type.
PR binutils/21665
* objdump.c (strtab): Make var a bfd_byte*.
(disassemble_section): Don't limit malloc size. Instead, use
bfd_malloc_and_get_section.
(read_section_stabs): Use bfd_malloc_and_get_section. Return
bfd_byte*.
(find_stabs_section): Remove now unnecessary cast.
* objcopy.c (copy_object): Use bfd_malloc_and_get_section. Free
contents on error return.
* nlmconv.c (copy_sections): Use bfd_malloc_and_get_section.
Diffstat (limited to 'binutils/nlmconv.c')
-rw-r--r-- | binutils/nlmconv.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/binutils/nlmconv.c b/binutils/nlmconv.c index 4cc659f..7e1eaac 100644 --- a/binutils/nlmconv.c +++ b/binutils/nlmconv.c @@ -1224,7 +1224,7 @@ copy_sections (bfd *inbfd, asection *insec, void *data_ptr) const char *inname; asection *outsec; bfd_size_type size; - void *contents; + bfd_byte *contents; long reloc_size; bfd_byte buf[4]; bfd_size_type add; @@ -1240,9 +1240,7 @@ copy_sections (bfd *inbfd, asection *insec, void *data_ptr) contents = NULL; else { - contents = xmalloc (size); - if (! bfd_get_section_contents (inbfd, insec, contents, - (file_ptr) 0, size)) + if (!bfd_malloc_and_get_section (inbfd, insec, &contents)) bfd_fatal (bfd_get_filename (inbfd)); } |