dnsproxy: Do not unref g_io_channel if we know it is null
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Fri, 26 Apr 2013 12:51:16 +0000 (15:51 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Tue, 30 Apr 2013 10:43:20 +0000 (13:43 +0300)
Currently tethering does not support IPv6 so its listener is
not created and is null. This will cause following output

connmand[18363]: src/dnsproxy.c:destroy_tcp_listener() index 31
(connmand:18363): GLib-CRITICAL **: g_io_channel_unref: assertion `channel != NULL' failed
connmand[18363]: src/dnsproxy.c:destroy_udp_listener() index 31
(connmand:18363): GLib-CRITICAL **: g_io_channel_unref: assertion `channel != NULL' failed

src/dnsproxy.c

index 4ad4eb6..9030a35 100644 (file)
@@ -3345,8 +3345,10 @@ static void destroy_udp_listener(struct listener_data *ifdata)
        if (ifdata->udp6_listener_watch > 0)
                g_source_remove(ifdata->udp6_listener_watch);
 
-       g_io_channel_unref(ifdata->udp4_listener_channel);
-       g_io_channel_unref(ifdata->udp6_listener_channel);
+       if (ifdata->udp4_listener_channel != NULL)
+               g_io_channel_unref(ifdata->udp4_listener_channel);
+       if (ifdata->udp6_listener_channel != NULL)
+               g_io_channel_unref(ifdata->udp6_listener_channel);
 }
 
 static void destroy_tcp_listener(struct listener_data *ifdata)
@@ -3358,8 +3360,10 @@ static void destroy_tcp_listener(struct listener_data *ifdata)
        if (ifdata->tcp6_listener_watch > 0)
                g_source_remove(ifdata->tcp6_listener_watch);
 
-       g_io_channel_unref(ifdata->tcp4_listener_channel);
-       g_io_channel_unref(ifdata->tcp6_listener_channel);
+       if (ifdata->tcp4_listener_channel != NULL)
+               g_io_channel_unref(ifdata->tcp4_listener_channel);
+       if (ifdata->tcp6_listener_channel != NULL)
+               g_io_channel_unref(ifdata->tcp6_listener_channel);
 }
 
 static int create_listener(struct listener_data *ifdata)