This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH 3/5][libbacktrace] Fix memory leak in loop in build_address_map
- From: "Ian Lance Taylor via gcc-patches" <gcc-patches at gcc dot gnu dot org>
- To: Tom de Vries <tdevries at suse dot de>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, Ian Lance Taylor <ian at airs dot com>
- Date: Thu, 27 Dec 2018 08:30:04 -0800
- Subject: Re: [PATCH 3/5][libbacktrace] Fix memory leak in loop in build_address_map
- References: <20181128231653.GA3990@delia>
- Reply-to: Ian Lance Taylor <iant at google dot com>
On Wed, Nov 28, 2018 at 3:17 PM Tom de Vries <firstname.lastname@example.org> wrote:
> When failing in build_address_map, we free the unit that's currently being
> handled in the loop, but the ones that already have been allocated are leaked.
> Fix this by keeping track of allocated units in a vector, and releasing them
> upon failure.
> Also, now that we have a vector of allocated units, move the freeing upon
> failure of the abbrevs associated with each unit to build_address_map, and
> remove the now redundant call to free_unit_addrs_vector.
> Bootstrapped and reg-tested on x86_64.
> OK for trunk?
> - Tom
> [libbacktrace] Fix memory leak in loop in build_address_map
> 2018-11-28 Ian Lance Taylor <email@example.com>
> Tom de Vries <firstname.lastname@example.org>
> PR libbacktrace/88063
> * dwarf.c (free_unit_addrs_vector): Remove.
> (build_address_map): Keep track of allocated units in vector. Free
> allocated units and corresponding abbrevs upon failure. Remove now
> redundant call to free_unit_addrs_vector. Free addrs vector upon
> failure. Free allocated unit vector.
This is OK.