This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v9 02/29] btrace, linux: fix memory leak when reading branch trace
- From: Markus Metzger <markus dot t dot metzger at intel dot com>
- To: jan dot kratochvil at redhat dot com, palves at redhat dot com
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 19 Dec 2013 17:44:32 +0100
- Subject: [PATCH v9 02/29] btrace, linux: fix memory leak when reading branch trace
- Authentication-results: sourceware.org; auth=none
- References: <1387471499-29444-1-git-send-email-markus dot t dot metzger at intel dot com>
When it takes more than one iteration to read the BTS trace, the trace from the
previous iteration is leaked. Fix it.
2013-12-19 Markus Metzger <markus.t.metzger@intel.com>
* common/linux-btrace.c (linux_read_btrace): Free trace from
previous iteration.
---
gdb/common/linux-btrace.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/gdb/common/linux-btrace.c b/gdb/common/linux-btrace.c
index 7e20745..2e0cd8e 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)
{
--
1.8.3.1