summaryrefslogtreecommitdiff
path: root/src/dnsproxy.c
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2012-11-16 14:12:46 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-11-19 14:53:24 +0200
commit792c02f6b72cecb1ba2ad1ed2cf496e655c7d977 (patch)
tree955fb425f2dab12f824dcd632e7cd530a983feb9 /src/dnsproxy.c
parenta3c241e74ce36b53e8105c76971eec9acc5cba74 (diff)
downloadconnman-792c02f6b72cecb1ba2ad1ed2cf496e655c7d977.tar.gz
connman-792c02f6b72cecb1ba2ad1ed2cf496e655c7d977.tar.bz2
connman-792c02f6b72cecb1ba2ad1ed2cf496e655c7d977.zip
dnsproxy: Check GIO channel for NULL before use
Check GIO channel for NULL before using it. Also shut down the GIO channel so that already pending input will not use the free'd structure.
Diffstat (limited to 'src/dnsproxy.c')
-rw-r--r--src/dnsproxy.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index bfd0e3eb..01bcc51a 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -1765,8 +1765,11 @@ static void server_destroy_socket(struct server_data *data)
data->timeout = 0;
}
- g_io_channel_unref(data->channel);
- data->channel = NULL;
+ if (data->channel != NULL) {
+ g_io_channel_shutdown(data->channel, TRUE, NULL);
+ g_io_channel_unref(data->channel);
+ data->channel = NULL;
+ }
g_free(data->incoming_reply);
data->incoming_reply = NULL;
@@ -1777,7 +1780,8 @@ static void destroy_server(struct server_data *server)
GList *list;
DBG("interface %s server %s sock %d", server->interface, server->server,
- g_io_channel_unix_get_fd(server->channel));
+ server->channel != NULL ?
+ g_io_channel_unix_get_fd(server->channel): -1);
server_list = g_slist_remove(server_list, server);
server_destroy_socket(server);