[lttng-dev] [PATCH babeltrace-1.5 4/6] Fix: lib/iterator.c: unbalanced ctx put (leak)

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Thu Dec 5 01:58:07 EST 2019


Missing context put in iterator init error path.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 lib/iterator.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/iterator.c b/lib/iterator.c
index 639a2d29..77093217 100644
--- a/lib/iterator.c
+++ b/lib/iterator.c
@@ -778,6 +778,8 @@ int bt_iter_init(struct bt_iter *iter,
 error:
 	bt_heap_free(iter->stream_heap);
 error_heap_init:
+	bt_context_put(ctx);
+	iter->ctx = NULL;
 	g_free(iter->stream_heap);
 	iter->stream_heap = NULL;
 error_ctx:
@@ -812,6 +814,7 @@ void bt_iter_fini(struct bt_iter *iter)
 	}
 	iter->ctx->current_iterator = NULL;
 	bt_context_put(iter->ctx);
+	iter->ctx = NULL;
 }
 
 void bt_iter_destroy(struct bt_iter *iter)
-- 
2.17.1



More information about the lttng-dev mailing list