Missing check for NULL
Alan Modra
amodra@gmail.com
Wed Sep 13 06:39:43 GMT 2023
On Tue, Sep 12, 2023 at 05:24:03PM +0200, jacob navia wrote:
> Hi
> HOW TO FIX: Add a check after the allocation:
> If (rel_hdr == NULL) return false;
Yes.
* elf.c (_bfd_elf_init_reloc_shdr): Don't segfault on alloc fail.
diff --git a/bfd/elf.c b/bfd/elf.c
index d7109f14039..fa8881e8ea6 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3659,6 +3659,8 @@ _bfd_elf_init_reloc_shdr (bfd *abfd,
BFD_ASSERT (reldata->hdr == NULL);
rel_hdr = bfd_zalloc (abfd, sizeof (*rel_hdr));
+ if (rel_hdr == NULL)
+ return false;
reldata->hdr = rel_hdr;
if (delay_st_name_p)
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list