summaryrefslogtreecommitdiff
path: root/libbacktrace/dwarf.c
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2018-12-28 03:43:15 +0000
committerTom de Vries <vries@gcc.gnu.org>2018-12-28 03:43:15 +0000
commit53a52133a5fc74d63ce17b328774706bf1e79e02 (patch)
treebb5714dffebc534c285ee313fee9c02d9645cbce /libbacktrace/dwarf.c
parentf14303090835f84474b6bf8c38bc0d07dbfc2069 (diff)
[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
Diffstat (limited to 'libbacktrace/dwarf.c')
-rw-r--r--libbacktrace/dwarf.c5
1 files changed, 5 insertions, 0 deletions
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;
}