solib_target_free_so memory leak
authorHannes Domani <ssbssa@yahoo.de>
Fri, 27 Dec 2019 12:41:58 +0000 (13:41 +0100)
committerHannes Domani <ssbssa@yahoo.de>
Fri, 3 Jan 2020 16:58:19 +0000 (17:58 +0100)
gdb/ChangeLog:

2020-01-03  Hannes Domani  <ssbssa@yahoo.de>

* solib-target.c (struct lm_info_target):
Change offsets to be a unique_xmalloc_ptr.
(solib_target_relocate_section_addresses): Update.

gdb/ChangeLog
gdb/solib-target.c

index a7817d64ff9e3625238acc82d2f73b7d185d8f36..3b26a3114f5003eee0797afe7f31bd69b1e85908 100644 (file)
@@ -1,3 +1,9 @@
+2020-01-03  Hannes Domani  <ssbssa@yahoo.de>
+
+       * 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  <ssbssa@yahoo.de>
 
        * windows-nat.c (windows_clear_solib): Free so_list linked list.
index 113211a92bceb2accf5918b1b9bad1afabf6094a..e90107e578256f3ea5a9969e9855f6b5c5e00036 100644 (file)
@@ -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<section_offsets> offsets;
 };
 
 typedef std::vector<std::unique_ptr<lm_info_target>> 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 (_("\