bugfix in remove_from_channels.
authorPekka Riikonen <priikone@silcnet.org>
Mon, 9 Oct 2000 13:43:06 +0000 (13:43 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 9 Oct 2000 13:43:06 +0000 (13:43 +0000)
apps/silcd/server.c

index 59746f07fa6605c45b11e63f1ffa66bb46996c04..ad62465da1349eb1ac1758cb7fb1c6b3644c9325 100644 (file)
@@ -2221,9 +2221,6 @@ void silc_server_remove_from_channels(SilcServer server,
   SilcChannelEntry channel;
   SilcBuffer id_payload;
 
-  id_payload = silc_id_payload_encode(channel->id, SILC_ID_CHANNEL_LEN,
-                                     SILC_ID_CHANNEL);
-
   /* Remove the client from all channels. The client is removed from
      the channels' user list. */
   for (i = 0; i < client->channel_count; i++) {
@@ -2231,6 +2228,9 @@ void silc_server_remove_from_channels(SilcServer server,
     if (!channel)
       continue;
 
+    id_payload = silc_id_payload_encode(channel->id, SILC_ID_CHANNEL_LEN,
+                                       SILC_ID_CHANNEL);
+
     /* Remove from channel */
     for (k = 0; k < channel->user_list_count; k++) {
       if (channel->user_list[k].client == client) {
@@ -2276,12 +2276,13 @@ void silc_server_remove_from_channels(SilcServer server,
                                           id_payload->len);
       }
     }
+
+    silc_id_payload_free(id_payload);
   }
 
   if (client->channel_count)
     silc_free(client->channel);
   client->channel = NULL;
-  silc_buffer_free(id_payload);
 }
 
 /* Removes client from one channel. This is used for example when client