This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: robustify bfd/linker.c:archive_hash_newfunc
- From: Ben Elliston <bje at au1 dot ibm dot com>
- To: binutils at sourceware dot org
- Date: Tue, 24 Oct 2006 17:00:56 +1000
- Subject: 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;
}