This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] linker.c, check for null return from bfd_hash_allocate
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: msnyder at sonic dot net
- Cc: binutils at sourceware dot org
- Date: Thu, 26 Jul 2007 23:37:11 +0930
- Subject: Re: [PATCH] linker.c, check for null return from bfd_hash_allocate
- References: <6375.12.7.175.2.1185415194.squirrel@webmail.sonic.net>
On Wed, Jul 25, 2007 at 06:59:54PM -0700, msnyder@sonic.net wrote:
> *** linker.c 24 Jul 2007 23:38:13 -0000 1.60
> --- linker.c 26 Jul 2007 01:55:13 -0000
> *************** bfd_section_already_linked_table_insert
> *** 2933,2938 ****
> --- 2933,2940 ----
> /* Allocate the memory from the same obstack as the hash table is
> kept in. */
> l = bfd_hash_allocate (&_bfd_section_already_linked_table, sizeof *l);
> + if (l == NULL)
> + return; /* Should we abort? */
The proper fix is to change bfd_section_already_linked_table_insert to
return a pass/fail status. Check the status in
_bfd_elf_section_already_linked, _bfd_generic_section_already_linked,
and on failure call info->einfo with a fatal error message.
> l->sec = sec;
> l->next = already_linked_list->entry;
> already_linked_list->entry = l;
> *************** already_linked_newfunc (struct bfd_hash_
> *** 2946,2951 ****
> --- 2948,2956 ----
> struct bfd_section_already_linked_hash_entry *ret =
> bfd_hash_allocate (table, sizeof *ret);
>
> + if (ret == NULL)
> + return ret;
> +
> ret->entry = NULL;
>
> return &ret->root;
This part is OK.
--
Alan Modra
Australia Development Lab, IBM