updates
[silc.git] / lib / silcclient / client.c
index b1099389aad451abc0a181d53476476256349c72..964df1805065791a8bff40d9b1adec99310ecbfa 100644 (file)
@@ -374,8 +374,10 @@ static void silc_client_start_key_exchange_cb(SilcSocketConnection sock,
 
   SILC_LOG_DEBUG(("Start"));
 
-  if (!conn->sock->hostname)
-    conn->sock->hostname = strdup(conn->remote_host);
+  /* XXX We should most likely use the resolved host name instead of the
+     one user provided for us. */
+  silc_free(conn->sock->hostname);
+  conn->sock->hostname = strdup(conn->remote_host);
   if (!conn->sock->ip)
     conn->sock->ip = strdup(conn->remote_host);
   conn->sock->port = conn->remote_port;
@@ -455,6 +457,8 @@ SILC_TASK_CALLBACK(silc_client_connect_failure)
   SilcClient client = (SilcClient)ctx->client;
 
   client->internal->ops->connect(client, ctx->sock->user_data, FALSE);
+  if (ctx->packet)
+    silc_packet_context_free(ctx->packet);
   silc_free(ctx);
 }
 
@@ -1056,7 +1060,8 @@ void silc_client_packet_parse_type(SilcClient client,
        
        if (proto_ctx->packet)
          silc_packet_context_free(proto_ctx->packet);
-       
+        if (proto_ctx->dest_id)
+          silc_free(proto_ctx->dest_id);
        proto_ctx->packet = silc_packet_context_dup(packet);
        proto_ctx->dest_id_type = packet->src_id_type;
        proto_ctx->dest_id = silc_id_str2id(packet->src_id, packet->src_id_len,
@@ -1365,13 +1370,15 @@ void silc_client_close_connection(SilcClient client,
 
     /* Clear ID caches */
     if (conn->client_cache)
-      silc_idcache_del_all(conn->client_cache);
+      silc_idcache_free(conn->client_cache);
     if (conn->channel_cache)
-      silc_idcache_del_all(conn->channel_cache);
+      silc_idcache_free(conn->channel_cache);
     if (conn->server_cache)
-      silc_idcache_del_all(conn->server_cache);
+      silc_idcache_free(conn->server_cache);
 
     /* Free data (my ID is freed in above silc_client_del_client) */
+    if (conn->nickname)
+      silc_free(conn->nickname);
     if (conn->remote_host)
       silc_free(conn->remote_host);
     if (conn->local_id_data)
@@ -1502,7 +1509,7 @@ void silc_client_receive_new_id(SilcClient client,
   if (!conn->local_entry)
     conn->local_entry = silc_calloc(1, sizeof(*conn->local_entry));
 
-  conn->local_entry->nickname = conn->nickname;
+  conn->local_entry->nickname = strdup(conn->nickname);
   if (!conn->local_entry->username)
     conn->local_entry->username = strdup(client->username);
   if (!conn->local_entry->hostname)