This is the mail archive of the binutils@sourceware.org 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: bfd_get_full_section_contents memory leak, plus


On Tue, Oct 16, 2012 at 09:12:10PM -0600, Tom Tromey wrote:
> I noticed that bfd_get_full_section_contents has a memory leak.  If you
> set BFD_DECOMPRESS on the BFD, then use bfd_get_full_section_contents to
> read a compressed section, the uncompressed section data will be
> malloc'd and stored as section->contents -- but nothing ever frees this.
> 
> My fix for this (appended) is to allocate the uncompressed data on the
> BFD's objalloc.

Not OK.  bfd_malloc_and_get_section calls bfd_get_full_section_contents.
The data must be malloc'd because users of b_m_a_g_s free it.

-- 
Alan Modra
Australia Development Lab, IBM


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