This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Return NULL on NULL bfd (Problem with linker with binutils-040414)


Alan Modra <amodra@bigpond.net.au> writes:

> On Mon, Apr 19, 2004 at 04:50:48PM -0400, Ian Lance Taylor wrote:
> > I actually see that bfd_archive_filename hides a bfd_malloc failure by
> > returning an incorrect value.  I also see that it unpredictably causes
> > a space leak.  I think this function needs some more attention in any
> > case.  If the comment is true that it is only used when building error
> > messages, then none of this matters very much.
> 
> The comment is true.  What space leak?

Whoops, sorry.  The memory area is stored in a static variable, so
there is no space leak.  Mea culpa.

On the other hand there is a different problem, which is that
bfd_archive_filename is not thread safe, and it is not safe to do
something like
    printf ("%s requires %s\n", bfd_archive_filename (b1),
            bfd_archive_filename (b2));

It would be safe to use bfd_alloc here, although that would cause a
different type of space leak if the function were called frequently.

I wouldn't worry about any of this if bfd_archive_filename were an
internal function.  But it is declared in bfd.h, so it must in some
sense be an external function.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]