From: Julien Desfossez Date: Mon, 23 Apr 2012 14:41:18 +0000 (-0400) Subject: Fix : double destroy in context remove X-Git-Tag: v1.0.0-rc2~2 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=188e72bf705ebe0276e7966a9bf46b74e583bcfc;ds=sidebyside 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 --- 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