From 1e0002d7e920bb2073df222ed5470f83602b16cb Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Fri, 20 Jan 2017 16:11:01 -0500 Subject: [PATCH] Fix writer: leak of the event classes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We have to release the writer_event_class once it is added to the writer_stream_class. This also highlighted a problem with the ownership of the stream, stream_class and writer objects which is now fixed. Signed-off-by: Julien Desfossez Signed-off-by: Jérémie Galarneau --- plugins/writer/write.c | 2 ++ plugins/writer/writer.c | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/writer/write.c b/plugins/writer/write.c index 970eaea0..5ee5d066 100644 --- a/plugins/writer/write.c +++ b/plugins/writer/write.c @@ -333,6 +333,7 @@ enum bt_component_status copy_event_classes(FILE *err, goto end; } bt_put(event_class); + bt_put(writer_event_class); } end: @@ -732,6 +733,7 @@ struct bt_ctf_stream *get_writer_stream( } else { writer_stream = insert_new_stream(writer_component, ctf_writer, stream_class, stream); + bt_get(writer_stream); } bt_put(ctf_writer); diff --git a/plugins/writer/writer.c b/plugins/writer/writer.c index f89ac746..48c3152a 100644 --- a/plugins/writer/writer.c +++ b/plugins/writer/writer.c @@ -69,22 +69,19 @@ void finalize_writer_component(struct bt_private_component *component) static void unref_stream_class(struct bt_ctf_stream_class *writer_stream_class) { - BT_PUT(writer_stream_class); - g_free(writer_stream_class); + return; } static void unref_stream(struct bt_ctf_stream_class *writer_stream) { - BT_PUT(writer_stream); - g_free(writer_stream); + bt_put(writer_stream); } static void unref_trace(struct bt_ctf_writer *writer) { - BT_PUT(writer); - g_free(writer); + return; } static -- 2.34.1