Static analyzer bug fixes
[silc.git] / apps / silcd / packet_send.c
index efc334cd1069803872a5df09a4eef7ccf511d821..2caacd2b271f1225db9f27f32bc6bc56450a2f8e 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2007 Pekka Riikonen
+  Copyright (C) 1997 - 2009 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -319,6 +319,8 @@ void silc_server_packet_send_to_channel(SilcServer server,
 
   routed = silc_calloc(silc_hash_table_count(channel->user_list),
                       sizeof(*routed));
+  if (!routed)
+    goto out;
 
   /* Send the message to clients on the channel's client list. */
   silc_hash_table_list(channel->user_list, &htl);
@@ -528,8 +530,15 @@ void silc_server_packet_relay_to_channel(SilcServer server,
     }
   }
 
+  if (!silc_hash_table_count(channel->user_list)) {
+    SILC_LOG_DEBUG(("Channel %s is empty", channel->channel_name));
+    return;
+  }
+
   routed = silc_calloc(silc_hash_table_count(channel->user_list),
                       sizeof(*routed));
+  if (!routed)
+    return;
 
   /* Assure we won't route the message back to the sender's way. */
   if (sender_entry->router)
@@ -1572,6 +1581,15 @@ void silc_server_send_dest_command_reply(SilcServer server,
   va_end(ap);
 }
 
+/* Send the heartbeat packet. */
+
+void silc_server_send_heartbeat(SilcServer server,
+                               SilcPacketStream sock)
+{
+  silc_server_packet_send(server, sock, SILC_PACKET_HEARTBEAT, 0,
+                         NULL, 0);
+}
+
 /* Routine used to send the connection authentication packet. */
 
 void silc_server_send_connection_auth_request(SilcServer server,