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: Statically identified memory leaks in ld


I haven't exhaustively review this but:

On Mon, Mar 24, 2003 at 11:08:45AM -0800, David Heine wrote:
> Index: bfd/aoutx.h
> ===================================================================
> RCS file: /cvs/src/src/bfd/aoutx.h,v
> retrieving revision 1.39
> diff -c -r1.39 aoutx.h
> *** bfd/aoutx.h	31 Dec 2002 07:29:25 -0000	1.39
> --- bfd/aoutx.h	24 Mar 2003 17:59:37 -0000
> ***************
> *** 3073,3079 ****
>     if (! NAME(aout,link_hash_table_init) (ret, abfd,
>   					 NAME(aout,link_hash_newfunc)))
>       {
> !       free (ret);
>         return (struct bfd_link_hash_table *) NULL;
>       }
>     return &ret->root;
> --- 3073,3082 ----
>     if (! NAME(aout,link_hash_table_init) (ret, abfd,
>   					 NAME(aout,link_hash_newfunc)))
>       {
> !       /* Can not free the result of bfd_alloc().  Either use bfd_malloc()
> ! 	 or it must leak.  A free of "ret" could result in
> ! 	 memory corruption here.
> ! 	 free (ret); */
>         return (struct bfd_link_hash_table *) NULL;
>       }
>     return &ret->root;

The hash table should be bfd_malloc'd.  I must have missed this one
when I converted them.


Also, every fix to free the results of a bfd_canonicalize_symtab is
missing the real problem; not only is the symbol table leaked, but the
_memory pointed to by the symbol table_ is leaked; that's much more
wasteful.  I haven't figured out how to fix it yet.

> Index: libiberty/cp-demangle.c

Where were you when I fixed dozens of leaks in the other demangler in
libiberty, huh huh? :P  I suppose I can feel gratified that you didn't
find any new ones in cplus-dem.c.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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