From: Alan Modra Date: Thu, 10 Nov 2022 23:22:43 +0000 (+1030) Subject: Sanity check SHT_MIPS_OPTIONS size X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d0e5049d8fa8e1994a42bb0296f72cc981b8ce8c;p=binutils-gdb.git Sanity check SHT_MIPS_OPTIONS size * elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Use bfd_malloc_and_get_section to read contents of .MIPS.options. --- diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index e0e23926f03..932167c15c6 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -7523,11 +7523,7 @@ _bfd_mips_elf_section_from_shdr (bfd *abfd, { bfd_byte *contents, *l, *lend; - contents = bfd_malloc (hdr->sh_size); - if (contents == NULL) - return false; - if (! bfd_get_section_contents (abfd, hdr->bfd_section, contents, - 0, hdr->sh_size)) + if (!bfd_malloc_and_get_section (abfd, hdr->bfd_section, &contents)) { free (contents); return false;