From: Tom de Vries Date: Fri, 28 Dec 2018 03:43:15 +0000 (+0000) Subject: [libbacktrace] Fix memory leak in build_address_map X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=53a52133a5fc74d63ce17b328774706bf1e79e02;p=gcc.git [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 * dwarf.c (build_address_map): Free addrs vector upon failure. From-SVN: r267442 --- diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog index d3d964b24b2..60e5f03d0f2 100644 --- a/libbacktrace/ChangeLog +++ b/libbacktrace/ChangeLog @@ -1,3 +1,7 @@ +2018-12-28 Tom de Vries + + * dwarf.c (build_address_map): Free addrs vector upon failure. + 2018-12-14 Tom de Vries PR testsuite/88491 diff --git a/libbacktrace/dwarf.c b/libbacktrace/dwarf.c index 48ef3638a5f..37a08ca29a8 100644 --- a/libbacktrace/dwarf.c +++ b/libbacktrace/dwarf.c @@ -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; }