From f82675af6510a48945237869b53c8fa82ba98933 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 27 Sep 2011 10:42:26 +0200 Subject: Fix connection finish, if not connected --- src/connection.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/connection.c b/src/connection.c index c93dbc7..73cd973 100644 --- a/src/connection.c +++ b/src/connection.c @@ -79,15 +79,19 @@ cmumble_connection_init(struct cmumble_context *ctx, int cmumble_connection_fini(struct cmumble_context *ctx) { - g_source_remove(g_source_get_id(ctx->con.source)); - g_source_unref(ctx->con.source); - - g_object_unref(G_OBJECT(ctx->con.input)); - g_object_unref(G_OBJECT(ctx->con.output)); + if (ctx->con.source) { + g_source_remove(g_source_get_id(ctx->con.source)); + g_source_unref(ctx->con.source); + } - g_io_stream_close(G_IO_STREAM(ctx->con.conn), NULL, NULL); - g_object_unref(G_OBJECT(ctx->con.conn)); - g_object_unref(G_OBJECT(ctx->con.sock_client)); + if (ctx->con.conn) { + g_object_unref(G_OBJECT(ctx->con.input)); + g_object_unref(G_OBJECT(ctx->con.output)); + g_io_stream_close(G_IO_STREAM(ctx->con.conn), NULL, NULL); + g_object_unref(G_OBJECT(ctx->con.conn)); + } + if (ctx->con.sock_client) + g_object_unref(G_OBJECT(ctx->con.sock_client)); return 0; } -- cgit