This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [patch] check for null return from bfd_malloc
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: msnyder at sonic dot net
- Cc: binutils at sourceware dot org
- Date: Fri, 6 Jul 2007 10:53:29 +0930
- Subject: Re: [patch] check for null return from bfd_malloc
- References: <19385.12.7.175.2.1183679761.squirrel@webmail.sonic.net>
On Thu, Jul 05, 2007 at 04:56:01PM -0700, msnyder@sonic.net wrote:
> It seems that most returns from bfd_malloc are checked for null...
Yes, they should be..
> *************** elf_collect_hash_codes (struct elf_link_
> *** 4988,4993 ****
> --- 4988,4995 ----
> if (p != NULL)
> {
> alc = bfd_malloc (p - name + 1);
> + if (alc == NULL)
> + return FALSE;
But unfortunately, returning FALSE here does not flag an error. All
it does is cut short the hash traversal. If you would like to fix
this properly you'll need to pass an error status back to
bfd_elf_size_dynsym_hash_dynstr. See elf_link_output_extsym for an
example of how this is done.
--
Alan Modra
Australia Development Lab, IBM