summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-09-27 10:42:26 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-09-27 10:42:26 +0200
commitf82675af6510a48945237869b53c8fa82ba98933 (patch)
treed2f9100f54f0ab5013dfe3689f76cd2801cc0455
parent0c5df9afd846a0a17ed2600fec3e744b86384743 (diff)
downloadcmumble-f82675af6510a48945237869b53c8fa82ba98933.tar.gz
cmumble-f82675af6510a48945237869b53c8fa82ba98933.tar.bz2
cmumble-f82675af6510a48945237869b53c8fa82ba98933.zip
Fix connection finish, if not connected
-rw-r--r--src/connection.c20
1 files 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;
}