[libbacktrace] Fix memory leak in build_address_map

While upon failure in build_address_map we call free_unit_addrs_vector, this
does not actually free the addrs vector, but merely the abbrevs of the units
pointed at by the elements of the addrs vector.

Fix this by adding code to build_address_map to make sure that the addrs vector
is freed upon failure.

Bootstrapped and reg-tested on x86_64.

2018-12-28  Tom de Vries  <tdevries@suse.de>

	* dwarf.c (build_address_map): Free addrs vector upon failure.

From-SVN: r267442
This commit is contained in:
Tom de Vries 2018-12-28 03:43:15 +00:00 committed by Tom de Vries
parent f143030908
commit 53a52133a5
2 changed files with 9 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2018-12-28 Tom de Vries <tdevries@suse.de>
* dwarf.c (build_address_map): Free addrs vector upon failure.
2018-12-14 Tom de Vries <tdevries@suse.de>
PR testsuite/88491

View File

@ -1552,6 +1552,11 @@ build_address_map (struct backtrace_state *state, uintptr_t base_address,
fail:
free_abbrevs (state, &abbrevs, error_callback, data);
free_unit_addrs_vector (state, addrs, error_callback, data);
if (addrs->count > 0)
{
backtrace_vector_free (state, &addrs->vec, error_callback, data);
addrs->count = 0;
}
return 0;
}