PATCH: some more tidy-ups
Ben Elliston
bje@au1.ibm.com
Tue May 9 08:07:00 GMT 2006
Hi Alan,
(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));
889
890 if (ret)
891 {
892 /* Initialize the local fields. */
893 ret->defs = NULL;
894 }
895
896 return &ret->root;
897 }
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?
Ben
More information about the Binutils
mailing list