diff mbox series

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

Message ID 20191205065809.16728-5-mathieu.desnoyers@efficios.com
State New
Headers show
Series Babeltrace 1.5 lttng-live with per-pid ust buffers | expand

Commit Message

Mathieu Desnoyers Dec. 5, 2019, 6:58 a.m. UTC
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 mbox series

Patch

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)