Do not crash if net_connect fails immediately.
authorPekka Riikonen <priikone@silcnet.org>
Tue, 22 Jul 2003 10:47:13 +0000 (10:47 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Tue, 22 Jul 2003 10:47:13 +0000 (10:47 +0000)
lib/silcclient/client.c
lib/silcclient/client_internal.h

index b01f4440315b619f9f09caafe2a823d07da2e1cc..9fc554bf5568f91e2d7e4033da3446747e861a33 100644 (file)
@@ -328,7 +328,8 @@ void silc_client_del_connection(SilcClient client, SilcClientConnection conn)
       silc_free(conn->internal->rekey);
 
       if (conn->internal->active_session) {
-       conn->sock->user_data = NULL;
+       if (conn->sock)
+         conn->sock->user_data = NULL;
        silc_client_ftp_session_free(conn->internal->active_session);
        conn->internal->active_session = NULL;
       }
@@ -898,7 +899,7 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_final)
    is used directly only in special cases. Normal cases should use
    silc_server_packet_send. Returns < 0 on error. */
 
-bool silc_client_packet_send_real(SilcClient client,
+int silc_client_packet_send_real(SilcClient client,
                                 SilcSocketConnection sock,
                                 bool force_send)
 {
@@ -1526,6 +1527,12 @@ void silc_client_close_connection_real(SilcClient client,
   if (!sock)
     sock = conn->sock;
 
+  if (!sock) {
+    if (del && conn)
+      silc_client_del_connection(client, conn);
+    return;
+  }
+
   /* We won't listen for this connection anymore */
   silc_schedule_unset_listen_fd(client->schedule, sock->sock);
 
index 20d05d0a1e0c9989d57a82a210931adccafe9ee9..0f98d3336571c82ac779ed3994bc938c3d19f91d 100644 (file)
@@ -221,7 +221,7 @@ void silc_client_packet_send(SilcClient client,
                              unsigned char *data,
                              SilcUInt32 data_len,
                              bool force_send);
-bool silc_client_packet_send_real(SilcClient client,
+int silc_client_packet_send_real(SilcClient client,
                                 SilcSocketConnection sock,
                                 bool force_send);
 void silc_client_ftp_free_sessions(SilcClient client,