[patch v6 01/21] btrace, linux: fix memory leak when reading branch trace

Markus Metzger markus.t.metzger@intel.com
Fri Sep 20 11:31:00 GMT 2013


When it takes more than one iteration to read the BTS trace, the trace from the
previous iteration is leaked.  Fix it.

2013-09-20  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 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/gdb/common/linux-btrace.c b/gdb/common/linux-btrace.c
index b874c84..9fd2dc5 100644
--- a/gdb/common/linux-btrace.c
+++ b/gdb/common/linux-btrace.c
@@ -517,6 +517,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.7.1



More information about the Gdb-patches mailing list