From ed9edfb5d5edb1dd0b6280ae4acdd9963a12ebe6 Mon Sep 17 00:00:00 2001 From: Markus Metzger Date: Mon, 3 Jun 2013 14:32:15 +0200 Subject: [PATCH] btrace, linux: fix memory leak when reading branch trace When it takes more than one iteration to read the BTS trace, the trace from the previous iteration is leaked. Fix it. 2014-01-16 Markus Metzger * common/linux-btrace.c (linux_read_btrace): Free trace from previous iteration. --- gdb/ChangeLog | 5 +++++ gdb/common/linux-btrace.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0305e985c4..e1e6c74461 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-01-16 Markus Metzger + + * common/linux-btrace.c (linux_read_btrace): Free trace from + previous iteration. + 2014-01-15 Doug Evans * dwarf2read.c (open_and_init_dwp_file): Use pulongest to print diff --git a/gdb/common/linux-btrace.c b/gdb/common/linux-btrace.c index ef240f707e..0d36ea5c95 100644 --- a/gdb/common/linux-btrace.c +++ b/gdb/common/linux-btrace.c @@ -520,6 +520,9 @@ linux_read_btrace (struct btrace_target_info *tinfo, { data_head = header->data_head; + /* Delete any leftover trace from the previous iteration. */ + VEC_free (btrace_block_s, btrace); + /* If there's new trace, let's read it. */ if (data_head != tinfo->data_head) { -- 2.34.1