[PATCH] Include alloca.h for bfd

Thiemo Seufer ica2_ts@csv.ica.uni-stuttgart.de
Thu Aug 23 09:15:00 GMT 2001


Jakub Jelinek wrote:
[snip]
> > -	      char *buf = alloca (strlen (h->root.string) + 10);
> > +	      char *buf = (char *) bfd_malloc (strlen (h->root.string) + 10);
> 
> You need to check return value - bfd_malloc can return NULL (but will set
> bfd error).

Argh. I _knew_ I've forgotten something.


2001-08-23  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>

	/bfd/ChangeLog
	* linker.c (_bfd_generic_link_add_archive_symbols): Replace alloca()
	by bfd_malloc().


diff -BurpNX /bigdisk/src/binutils-exclude src-orig/bfd/linker.c src/bfd/linker.c
--- src-orig/bfd/linker.c	Sat Aug 18 21:47:22 2001
+++ src/bfd/linker.c	Thu Aug 23 18:09:21 2001
@@ -1007,9 +1007,13 @@ _bfd_generic_link_add_archive_symbols (a
 	     let's look for its import thunk */
 	  if (info->pei386_auto_import)
 	    {
-	      char *buf = alloca (strlen (h->root.string) + 10);
+	      char *buf = (char *) bfd_malloc (strlen (h->root.string) + 10);
+	      if (buf == NULL)
+		return false;
+
 	      sprintf (buf, "__imp_%s", h->root.string);
 	      arh = archive_hash_lookup (&arsym_hash, buf, false, false);
+	      free(buf);
 	    }
 	  if (arh == (struct archive_hash_entry *) NULL)
 	    {



More information about the Binutils mailing list