This is the mail archive of the gdb-patches@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]

[PATCH] Free synthsyms and member names in function elf_read_minimal_symbols.


The memory for synthsyms and synthsyms->name is allocated in elf64-x86-64.c
(elf_x86_64_get_synthetic_symtab). However, as shown by a valgrind memcheck,
this memory is not freed before synthsyms goes off the stack at the
termination of elf_read_minimal_symbols. This patch fixes that leak.
---
 gdb/ChangeLog | 5 +++++
 gdb/elfread.c | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 92c573d76b..3246fea02c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-08-08 Alex Lindsay <alexlindsay239@gmail.com>
+
+	* elfread.c (elf_read_minimal_symbols): Free synthsyms->name and
+	synthsyms
+
 2017-08-03  Tom Tromey  <tom@tromey.com>
 
 	* utils.c (make_cleanup_freeargv, do_freeargv, gdb_buildargv):
diff --git a/gdb/elfread.c b/gdb/elfread.c
index ece704ca7c..5ed8a6f957 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1144,6 +1144,9 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
 
   if (symtab_create_debug)
     fprintf_unfiltered (gdb_stdlog, "Done reading minimal symbols.\n");
+  if (synthcount > 0)
+    xfree ((char *) synthsyms->name);
+  xfree (synthsyms);
 }
 
 /* Scan and build partial symbols for a symbol file.
-- 
2.11.0


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