CAPI/Spp: Only unref Spp channel if socket is connected 26/26226/1
authorCorentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
Tue, 19 Aug 2014 09:15:56 +0000 (11:15 +0200)
committerCorentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
Tue, 19 Aug 2014 10:16:45 +0000 (12:16 +0200)
Spp channel is created at socket connection time, so if socket is created
but not connected , g_io_channel_shutdown() should not be called with a null channel.
Otherwise we get this glib error :
GLib-CRITICAL **: g_io_channel_shutdown: assertion `channel != NULL' failed

Change-Id: Ib013c42f3d9518945a4aba8b77922795795c3403
Signed-off-by: Corentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
capi/bluetooth.c

index a337636..f0216cc 100644 (file)
@@ -4126,9 +4126,11 @@ int bt_spp_destroy_rfcomm(const char *uuid)
 
        spp_ctx_list = g_list_remove(spp_ctx_list, spp_ctx);
 
-       g_io_channel_shutdown(spp_ctx->channel, TRUE, NULL);
 
-       g_io_channel_unref(spp_ctx->channel);
+       if (spp_ctx->channel) {
+         g_io_channel_shutdown(spp_ctx->channel, TRUE, NULL);
+         g_io_channel_unref(spp_ctx->channel);
+       }
 
        free_spp_context(spp_ctx);