From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Lance Taylor To: Andrew Cagney Cc: Thiemo Seufer , binutils@sources.redhat.com Subject: Re: [PATCH] Include alloca.h for bfd Date: Thu, 23 Aug 2001 10:29:00 -0000 Message-id: References: <20010821210909.E30301@rembrandt.csv.ica.uni-stuttgart.de> <20010821234604.J30301@rembrandt.csv.ica.uni-stuttgart.de> <20010823174716.E3542@rembrandt.csv.ica.uni-stuttgart.de> <20010823180440.F5765@sunsite.ms.mff.cuni.cz> <20010823181513.F3542@rembrandt.csv.ica.uni-stuttgart.de> <3B8539CD.5060306@cygnus.com> X-SW-Source: 2001-08/msg00541.html Andrew Cagney writes: > > > > Argh. I _knew_ I've forgotten something. > > 2001-08-23 Thiemo Seufer > > /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); > > Hmm, shame you can't use asprintf(). It does everything you want > except use bfd_malloc(). Now that you mention it, we could use asprintf there. There is an implementation in libiberty. If it can't allocate memory, it sets the buffer to NULL. Doesn't matter much, though. Ian