This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: bfd_get_full_section_contents memory leak, plus
- From: Alan Modra <amodra at gmail dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: Binutils Development <binutils at sourceware dot org>
- Date: Thu, 18 Oct 2012 11:07:33 +1030
- Subject: Re: bfd_get_full_section_contents memory leak, plus
- References: <87391d7px1.fsf@fleche.redhat.com>
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