This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Fix leak in solib-target.c:library_list_start_library


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2f667667e24357ff54701f3e046820cf08d649cf

commit 2f667667e24357ff54701f3e046820cf08d649cf
Author: Pedro Alves <palves@redhat.com>
Date:   Thu Jan 10 17:52:39 2019 +0000

    Fix leak in solib-target.c:library_list_start_library
    
    lm_info_target::name is nowadays std::string, so we're leaking the
    result of xstrdup.
    
    gdb/ChangeLog:
    2019-01-10  Pedro Alves  <palves@redhat.com>
    
    	* solib-target.c (library_list_start_library): Don't xstrdup name.

Diff:
---
 gdb/ChangeLog      | 4 ++++
 gdb/solib-target.c | 3 +--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b651980..1c036bb 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2019-01-10  Pedro Alves  <palves@redhat.com>
 
+	* solib-target.c (library_list_start_library): Don't xstrdup name.
+
+2019-01-10  Pedro Alves  <palves@redhat.com>
+
 	* mdebugread.c (parse_partial_symbols): Use
 	gdb::unique_xmalloc_ptr to manage heap-allocated 'stabsstring'.
 
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index 17b958e..972d9ef 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -124,10 +124,9 @@ library_list_start_library (struct gdb_xml_parser *parser,
 {
   VEC(lm_info_target_p) **list = (VEC(lm_info_target_p) **) user_data;
   lm_info_target *item = new lm_info_target;
-  const char *name
+  item->name
     = (const char *) xml_find_attribute (attributes, "name")->value.get ();
 
-  item->name = xstrdup (name);
   VEC_safe_push (lm_info_target_p, *list, item);
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]