This is the mail archive of the
mailing list for the binutils project.
Re: PATCH: some more tidy-ups
- From: Ben Elliston <bje at au1 dot ibm dot com>
- To: amodra at bigpond dot net dot au
- Cc: binutils at sourceware dot org
- Date: Tue, 9 May 2006 16:10:10 +1000
- Subject: Re: PATCH: some more tidy-ups
(Sorry for the broken threading; I dig up the quotes for this message
from the mailing list archives, so the References: will be wrong).
> > A couple of more tidy-ups. My change to linker.c should now prevent
> > the possibility of a segfault in BFD due to a null pointer dereference
> > (well, at least, it at least pushes it up a level!)
> I don't see any dereference.
No, but let's pull up the original source:
886 /* Call the allocation method of the superclass. */
887 ret = ((struct archive_hash_entry *)
888 bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
890 if (ret)
892 /* Initialize the local fields. */
893 ret->defs = NULL;
896 return &ret->root;
If the call to bfd_hash_newfunc returns NULL, then we skip
initialisation, but return &ret->root. It's lucky that `root' happens
to be the first member of the structure, so that the result of the
address expression is still 0. If the composition of this structure
were to ever change, we might return 4 or 8 in the failure case.
At the very least, this needs a loud comment. :-)
Do you agree?