From: jacob navia <jacob@jacob.remcomp.fr>
To: binutils@sourceware.org
Subject: Missing NULL check
Date: Tue, 12 Sep 2023 17:40:45 +0200 [thread overview]
Message-ID: <69AA9E49-F26A-4DAC-B120-70940C3A59B1@jacob.remcomp.fr> (raw)
[-- Attachment #1: Type: text/plain, Size: 1074 bytes --]
This is very similar to the last one:
FILE: elf-attrs.c line 232
FUNCTION: elf_new_obj_attr
/* Allocate/find an object attribute. */
static obj_attribute *
elf_new_obj_attr (bfd *abfd, int vendor, unsigned int tag)
{
obj_attribute *attr;
obj_attribute_list *list;
obj_attribute_list *p;
obj_attribute_list **lastp;
if (tag < NUM_KNOWN_OBJ_ATTRIBUTES)
{
/* Known tags are preallocated. */
attr = &elf_known_obj_attributes (abfd)[vendor][tag];
}
else
{
/* Create a new tag. */
list = (obj_attribute_list *)
bfd_alloc (abfd, sizeof (obj_attribute_list));
memset (list, 0, sizeof (obj_attribute_list));
list->tag = tag;
/* Keep the tag list in order. */
lastp = &elf_other_obj_attributes (abfd)[vendor];
for (p = *lastp; p; p = p->next)
{
if (tag < p->tag)
break;
lastp = &p->next;
}
list->next = *lastp;
*lastp = list;
attr = &list->attr;
}
return attr;
}
bfd_alloc can return NULL. This is not checked
How to fix:
Add
if (list == NULL) return NULL;
next reply other threads:[~2023-09-12 15:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-12 15:40 jacob navia [this message]
2023-09-12 18:50 ` Torbjorn SVENSSON
2023-09-12 19:34 ` Fangrui Song
2023-09-13 10:57 ` Nick Clifton
[not found] ` <DS7PR12MB5765DD3A03E4B143B950C3D6CBF1A@DS7PR12MB5765.namprd12.prod.outlook.com>
2023-09-13 14:28 ` jacob navia
2023-09-13 6:50 ` Alan Modra
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=69AA9E49-F26A-4DAC-B120-70940C3A59B1@jacob.remcomp.fr \
--to=jacob@jacob.remcomp.fr \
--cc=binutils@sourceware.org \
/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).