From 44f81a76542dbeada2541a05de191ae0ac0fbc2c Mon Sep 17 00:00:00 2001 From: Hannes Domani Date: Fri, 27 Dec 2019 13:41:58 +0100 Subject: solib_target_free_so memory leak gdb/ChangeLog: 2020-01-03 Hannes Domani * solib-target.c (struct lm_info_target): Change offsets to be a unique_xmalloc_ptr. (solib_target_relocate_section_addresses): Update. --- gdb/ChangeLog | 6 ++++++ gdb/solib-target.c | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a7817d6..3b26a31 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2020-01-03 Hannes Domani + * solib-target.c (struct lm_info_target): + Change offsets to be a unique_xmalloc_ptr. + (solib_target_relocate_section_addresses): Update. + +2020-01-03 Hannes Domani + * windows-nat.c (windows_clear_solib): Free so_list linked list. 2020-01-03 Bernd Edlinger diff --git a/gdb/solib-target.c b/gdb/solib-target.c index 113211a..e90107e 100644 --- a/gdb/solib-target.c +++ b/gdb/solib-target.c @@ -46,7 +46,7 @@ struct lm_info_target : public lm_info_base /* The cached offsets for each section of this shared library, determined from SEGMENT_BASES, or SECTION_BASES. */ - section_offsets *offsets = NULL; + gdb::unique_xmalloc_ptr offsets; }; typedef std::vector> lm_info_vector; @@ -309,9 +309,8 @@ solib_target_relocate_section_addresses (struct so_list *so, { int num_sections = gdb_bfd_count_sections (so->abfd); - li->offsets - = ((struct section_offsets *) - xzalloc (SIZEOF_N_SECTION_OFFSETS (num_sections))); + li->offsets.reset ((struct section_offsets *) + xzalloc (SIZEOF_N_SECTION_OFFSETS (num_sections))); if (!li->section_bases.empty ()) { @@ -377,7 +376,8 @@ Could not relocate shared library \"%s\": no segments"), so->so_name); ULONGEST orig_delta; int i; - if (!symfile_map_offsets_to_segments (so->abfd, data, li->offsets, + if (!symfile_map_offsets_to_segments (so->abfd, data, + li->offsets.get (), li->segment_bases.size (), li->segment_bases.data ())) warning (_("\ -- cgit v1.1