From 188e72bf705ebe0276e7966a9bf46b74e583bcfc Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Mon, 23 Apr 2012 10:41:18 -0400 Subject: [PATCH] Fix : double destroy in context remove The hashtable storing the trace handle is created with a destroy function that frees the elements when they are removed. Manually calling the destroy function after removing a handle for the table causes double-free problems. Fixes #197 Reported-by: Mathieu Denis Signed-off-by: Julien Desfossez Signed-off-by: Mathieu Desnoyers --- lib/context.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/context.c b/lib/context.c index d6b1ec8b..bedcc420 100644 --- a/lib/context.c +++ b/lib/context.c @@ -135,14 +135,13 @@ void bt_context_remove_trace(struct bt_context *ctx, int handle_id) /* Remove from containers */ trace_collection_remove(ctx->tc, handle->td); - g_hash_table_remove(ctx->trace_handles, - (gpointer) (unsigned long) handle_id); - /* Close the trace */ handle->format->close_trace(handle->td); - /* Destory the handle */ - bt_trace_handle_destroy(handle); + /* Remove and free the handle */ + g_hash_table_remove(ctx->trace_handles, + (gpointer) (unsigned long) handle_id); + } static -- 2.34.1