This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: some more tidy-ups

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));
   890    if (ret)
   891      {
   892        /* Initialize the local fields.  */
   893        ret->defs = NULL;
   894      }
   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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]