This is the mail archive of the binutils@sourceware.org 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]

PATCH: robustify bfd/linker.c:archive_hash_newfunc


I think the last time I raised this, I was told that `root' will
always be the first field of a struct archive_hash_entry.  That
bothers me .. is this more explicit handling of return values just as
acceptable?

Ben


2006-10-24  Ben Elliston  <bje@au.ibm.com>

        * linker.c (archive_hash_newfunc): Return NULL if ret is NULL,
        rather than assuming that `root' is the first field of a struct
        archive_hash_entry.

Index: linker.c
===================================================================
RCS file: /cvs/src/src/bfd/linker.c,v
retrieving revision 1.56
diff -u -p -r1.56 linker.c
--- linker.c    23 Oct 2006 02:35:38 -0000      1.56
+++ linker.c    24 Oct 2006 06:58:09 -0000
@@ -887,12 +887,11 @@ archive_hash_newfunc (struct bfd_hash_en
   ret = ((struct archive_hash_entry *)
         bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
 
-  if (ret)
-    {
-      /* Initialize the local fields.  */
-      ret->defs = NULL;
-    }
+  if (ret == NULL)
+    return NULL;
 
+  /* Initialize the local fields.  */
+  ret->defs = NULL;
   return &ret->root;
 }
 


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