From: Thadeu Lima de Souza Cascardo Date: Thu, 17 Oct 2013 11:38:23 +0000 (-0300) Subject: If received message has size 0, ignore it. X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Ff2fchat.git;a=commitdiff_plain;h=a35406f8da02aa40551c5bf7364d4e6890db018c If received message has size 0, ignore it. --- diff --git a/message.c b/message.c index 8c6dafd..4d3150a 100644 --- a/message.c +++ b/message.c @@ -48,6 +48,9 @@ gboolean message_incoming(GIOChannel *channel, GIOCondition cond, gpointer data) gusock = g_socket_new_from_fd(g_io_channel_unix_get_fd(channel), NULL); } len = g_socket_get_available_bytes(gusock); + if (len <= 0) { + goto out; + } buffer = g_malloc(len); len = g_socket_receive_from(gusock, &address, buffer, len, NULL, NULL); iaddress = g_inet_socket_address_get_address(G_INET_SOCKET_ADDRESS(address)); @@ -66,6 +69,7 @@ gboolean message_incoming(GIOChannel *channel, GIOCondition cond, gpointer data) } g_object_unref(address); g_free(buffer); +out: return TRUE; }