From 38cc67cc00dc7385991e2658a1b4213d5ba3c4f0 Mon Sep 17 00:00:00 2001 From: Jacob Navia Date: Wed, 13 Sep 2023 11:41:03 +0100 Subject: [PATCH] Fix: "Missing NULL check" * elf.c (_bfd_elf_init_reloc_shdr): Don't segfault on alloc fail. --- bfd/ChangeLog | 4 ++++ bfd/elf.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 20dd6ba9e8e..4b0544a2ac9 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,7 @@ +2023-09-13 Jacob Navia + + * elf.c (_bfd_elf_init_reloc_shdr): Don't segfault on alloc fail. + 2023-09-13 Alan Modra * elf-strtab.c (_bfd_elf_strtab_init): In the event of memory 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) -- 2.39.2