From: Alan Modra <amodra@gmail.com>
To: jacob navia <jacob@jacob.remcomp.fr>
Cc: binutils@sourceware.org
Subject: Re: Missing check for NULL
Date: Wed, 13 Sep 2023 16:09:43 +0930 [thread overview]
Message-ID: <ZQFZL5Oaz1/5LBbr@squeak.grove.modra.org> (raw)
In-Reply-To: <EE70F55F-18F9-4365-BC82-DE7F07A51EAA@jacob.remcomp.fr>
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
prev parent reply other threads:[~2023-09-13 6:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-12 15:24 jacob navia
2023-09-13 6:39 ` Alan Modra [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZQFZL5Oaz1/5LBbr@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=jacob@jacob.remcomp.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).