Added mising channel entry unreferencing calls.
authorPekka Riikonen <priikone@silcnet.org>
Tue, 13 Nov 2007 16:37:40 +0000 (16:37 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Tue, 13 Nov 2007 16:37:40 +0000 (16:37 +0000)
CHANGES.TOOLKIT
lib/silcclient/client_register.c
lib/silcclient/command_reply.c

index 9a6e6f3dd25105d846792be1040c328a5ac6f214..ffbc1f070e253d4d8fe4fca4f918345bec541360 100644 (file)
@@ -1,3 +1,9 @@
+Tue Nov 13 18:24:56 EET 2007 Pekka Riikonen <priikone@silcnet.org>
+
+       * Added missing channel unreferencing in CMODE, CUMODE,
+         TOPIC, INVITE, BAN and KICK command replies.  Affected
+         file is lib/silcclient/command_reply.c.
+
 Mon Nov  5 23:07:58 EET 2007  Pekka Riikonen <priikone@silcnet.org>
 
        * Zero tail of CTR mode IV in IV Included mode.  Change does
index 81c9d6af430a0ce86eb7589c0063c2d3cf54de24..72f10c1d1a5c4445614ee4c8ba6b95af7e70299b 100644 (file)
@@ -453,6 +453,8 @@ SILC_FSM_STATE(silc_client_st_resume_resolve_channels)
     channel = silc_client_get_channel_by_id(client, conn, &channel_id);
     if (!channel)
       silc_client_add_channel(client, conn, name, 0, &channel_id);
+    else
+      silc_client_unref_channel(client, conn, channel);
 
     res_argv = silc_realloc(res_argv, sizeof(*res_argv) * (res_argc + 1));
     res_argv_lens = silc_realloc(res_argv_lens, sizeof(*res_argv_lens) *
index ebcc94e587f9d8cbdb59f6c6bf494ac67f889105..d3c9f89ec429931ea51dacbb5a5b84f3733e8826 100644 (file)
@@ -822,7 +822,7 @@ SILC_FSM_STATE(silc_client_command_reply_topic)
   SilcClient client = conn->client;
   SilcCommandPayload payload = state_context;
   SilcArgumentPayload args = silc_command_get_args(payload);
-  SilcChannelEntry channel;
+  SilcChannelEntry channel = NULL;
   char *topic;
   SilcUInt32 len;
   SilcID id;
@@ -859,6 +859,7 @@ SILC_FSM_STATE(silc_client_command_reply_topic)
   silc_client_command_callback(cmd, channel, channel->topic);
 
  out:
+  silc_client_unref_channel(client, conn, channel);
   silc_fsm_next(fsm, silc_client_command_reply_processed);
   return SILC_FSM_CONTINUE;
 }
@@ -874,7 +875,7 @@ SILC_FSM_STATE(silc_client_command_reply_invite)
   SilcClient client = conn->client;
   SilcCommandPayload payload = state_context;
   SilcArgumentPayload args = silc_command_get_args(payload);
-  SilcChannelEntry channel;
+  SilcChannelEntry channel = NULL;
   unsigned char *tmp;
   SilcUInt32 len;
   SilcArgumentPayload invite_args = NULL;
@@ -909,6 +910,7 @@ SILC_FSM_STATE(silc_client_command_reply_invite)
     silc_argument_payload_free(invite_args);
 
  out:
+  silc_client_unref_channel(client, conn, channel);
   silc_fsm_next(fsm, silc_client_command_reply_processed);
   return SILC_FSM_CONTINUE;
 }
@@ -1419,7 +1421,7 @@ SILC_FSM_STATE(silc_client_command_reply_cmode)
   SilcArgumentPayload args = silc_command_get_args(payload);
   unsigned char *tmp;
   SilcUInt32 mode;
-  SilcChannelEntry channel;
+  SilcChannelEntry channel = NULL;
   SilcUInt32 len;
   SilcPublicKey public_key = NULL;
   SilcID id;
@@ -1479,7 +1481,22 @@ SILC_FSM_STATE(silc_client_command_reply_cmode)
   silc_client_command_callback(cmd, channel, mode, public_key,
                               channel->channel_pubkeys, channel->user_limit);
 
+  silc_rwlock_wrlock(channel->internal.lock);
+
+  /* If founder key changed, update it */
+  if (public_key &&
+      (!channel->founder_key ||
+       !silc_pkcs_public_key_compare(public_key, channel->founder_key))) {
+    if (channel->founder_key)
+      silc_pkcs_public_key_free(channel->founder_key);
+    channel->founder_key = public_key;
+    public_key = NULL;
+  }
+
+  silc_rwlock_unlock(channel->internal.lock);
+
  out:
+  silc_client_unref_channel(client, conn, channel);
   if (public_key)
     silc_pkcs_public_key_free(public_key);
   silc_fsm_next(fsm, silc_client_command_reply_processed);
@@ -1498,7 +1515,7 @@ SILC_FSM_STATE(silc_client_command_reply_cumode)
   SilcCommandPayload payload = state_context;
   SilcArgumentPayload args = silc_command_get_args(payload);
   SilcClientEntry client_entry;
-  SilcChannelEntry channel;
+  SilcChannelEntry channel = NULL;
   SilcChannelUser chu;
   unsigned char *modev;
   SilcUInt32 len, mode;
@@ -1555,6 +1572,7 @@ SILC_FSM_STATE(silc_client_command_reply_cumode)
   silc_client_unref_client(client, conn, client_entry);
 
  out:
+  silc_client_unref_channel(client, conn, channel);
   silc_fsm_next(fsm, silc_client_command_reply_processed);
   return SILC_FSM_CONTINUE;
 }
@@ -1569,7 +1587,7 @@ SILC_FSM_STATE(silc_client_command_reply_kick)
   SilcCommandPayload payload = state_context;
   SilcArgumentPayload args = silc_command_get_args(payload);
   SilcClientEntry client_entry;
-  SilcChannelEntry channel;
+  SilcChannelEntry channel = NULL;
   SilcID id;
 
   /* Sanity checks */
@@ -1608,6 +1626,7 @@ SILC_FSM_STATE(silc_client_command_reply_kick)
   silc_client_unref_client(client, conn, client_entry);
 
  out:
+  silc_client_unref_channel(client, conn, channel);
   silc_fsm_next(fsm, silc_client_command_reply_processed);
   return SILC_FSM_CONTINUE;
 }
@@ -1715,7 +1734,7 @@ SILC_FSM_STATE(silc_client_command_reply_ban)
   SilcClient client = conn->client;
   SilcCommandPayload payload = state_context;
   SilcArgumentPayload args = silc_command_get_args(payload);
-  SilcChannelEntry channel;
+  SilcChannelEntry channel = NULL;
   unsigned char *tmp;
   SilcUInt32 len;
   SilcArgumentPayload invite_args = NULL;
@@ -1750,6 +1769,7 @@ SILC_FSM_STATE(silc_client_command_reply_ban)
     silc_argument_payload_free(invite_args);
 
  out:
+  silc_client_unref_channel(client, conn, channel);
   silc_fsm_next(fsm, silc_client_command_reply_processed);
   return SILC_FSM_CONTINUE;
 }