Corrected a bug that causes segfaults if UDP packets are received when no client...
[umurmur.git] / src / client.c
index ce9af73bc0c900acde5a3633acbda21a985d7feb..74633613b744401636c10eee2c7a3b535d5f5bac 100644 (file)
@@ -377,8 +377,11 @@ int Client_send_message(client_t *client, message_t *msg)
 client_t *Client_iterate(client_t **client_itr)
 {
        client_t *c = *client_itr;
+
+       if (list_empty(&clients))
+               return NULL;
        
-       if (c == NULL && !list_empty(&clients)) {
+       if (c == NULL) {
                c = list_get_entry(list_get_first(&clients), client_t, node);
        } else {
                if (list_get_next(&c->node) == &clients)
@@ -527,10 +530,14 @@ static void Client_voiceMsg_tunnel(client_t *client, message_t *msg)
        Pds_add_numval(pds, msg->sessionId);
        Pds_add_numval(pds, msg->payload.speex.seq);
        Pds_append_data_nosize(pds, msg->payload.speex.data, msg->payload.speex.size);
+       
+       Msg_free(msg);
+       
        if (!pds->bOk)
                Log_warn("Large Speex message from TCP"); /* XXX - pds resize? */
        pds->maxsize = pds->offset;
        Client_voiceMsg(client, pds);
+       
        Pds_free(pds);
 }