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 linespec.c


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

commit 1055a3b422da11b252fc83e73a5e9f465233e73d
Author: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Date:   Mon Jan 7 16:02:51 2019 +0100

    Fix leak in linespec.c
    
    Valgrind reports a leak in many tests, such as:
    ==9382== 16 bytes in 1 blocks are definitely lost in loss record 236 of 3,282
    ==9382==    at 0x4C2BE6D: malloc (vg_replace_malloc.c:309)
    ==9382==    by 0x4197AF: xrealloc (common-utils.c:64)
    ==9382==    by 0x51D16A: xresizevec<linespec_canonical_name> (poison.h:170)
    ==9382==    by 0x51D16A: add_sal_to_sals(linespec_state*, std::vector<symtab_and_line, std::allocator<symtab_and_line> >*, symtab_and_line*, char const*, int) (linespec.c:1041)
    ==9382==    by 0x51E2BF: create_sals_line_offset (linespec.c:2215)
    ==9382==    by 0x51E2BF: convert_linespec_to_sals(linespec_state*, linespec*) (linespec.c:2358)
    ==9382==    by 0x521B5D: convert_explicit_location_to_sals (linespec.c:2473)
    
    Fix leak by xfree-ing self->canonical_names in linespec_state_destructor.
    The leak probably appeared with the patch 'Remove cleanup from linespec.c',
    as there was a cleanup to xfree canonical_names before the patch.
    
    Tested on Debian/amd64, native and under valgrind.
    
    2019-01-09  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
    
    	* linespec.c (linespec_state_destructor): Free self->canonical_names.

Diff:
---
 gdb/ChangeLog  | 4 ++++
 gdb/linespec.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d16d9e1..7d6d597 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2019-01-09  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
+
+	* linespec.c (linespec_state_destructor): Free self->canonical_names.
+
 2019-01-08  Tom Tromey  <tom@tromey.com>
 	    Simon Marchi  <simon.marchi@ericsson.com>
 
diff --git a/gdb/linespec.c b/gdb/linespec.c
index b1ab462..f6ef4c2 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -2767,6 +2767,7 @@ static void
 linespec_state_destructor (struct linespec_state *self)
 {
   htab_delete (self->addr_set);
+  xfree (self->canonical_names);
 }
 
 /* Delete a linespec parser.  */


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