From 1198c9d26848e2613d6080b4a1b3471379b699e8 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sun, 18 Feb 2007 10:09:19 +0000 Subject: [PATCH] Memory leak fixes. --- lib/doc/LIBINDEX | 2 ++ lib/silcapputil/silcapputil.h | 10 +++++----- lib/silcclient/client.c | 7 ------- lib/silcclient/client_connect.c | 3 +++ lib/silcclient/client_ftp.c | 4 +++- lib/silccore/silcpacket.c | 6 +----- lib/silcutil/silcmutex.h | 3 ++- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/lib/doc/LIBINDEX b/lib/doc/LIBINDEX index ece0a0a7..ebecb16c 100644 --- a/lib/doc/LIBINDEX +++ b/lib/doc/LIBINDEX @@ -25,6 +25,8 @@ Toolkit sources, and the documentation is constantly evolving. New versions of the Toolkit always delivers the latest version of this reference manual.


+
  • What's new in Toolkit 1.1
    +
  • Porting from Toolkit 1.0 to 1.1
  • Introduction to the Manual
  • Programming Conventions
  • Building the Toolkit diff --git a/lib/silcapputil/silcapputil.h b/lib/silcapputil/silcapputil.h index 31964a46..f4858d2a 100644 --- a/lib/silcapputil/silcapputil.h +++ b/lib/silcapputil/silcapputil.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2002 - 2006 Pekka Riikonen + Copyright (C) 2002 - 2007 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 @@ -289,10 +289,10 @@ unsigned char *silc_channel_name_check(const unsigned char *identifier, * SYNOPSIS * * SilcBool - * silc_channel_name_check(const unsigned char *identifier, - * SilcUInt32 identifier_len, - * SilcStringEncoding identifier_encoding, - * SilcUInt32 max_allowed_length); + * silc_channel_name_veirfy(const unsigned char *identifier, + * SilcUInt32 identifier_len, + * SilcStringEncoding identifier_encoding, + * SilcUInt32 max_allowed_length); * * DESCRIPTION * diff --git a/lib/silcclient/client.c b/lib/silcclient/client.c index 1d788455..c939fa7b 100644 --- a/lib/silcclient/client.c +++ b/lib/silcclient/client.c @@ -867,13 +867,6 @@ void silc_client_close_connection(SilcClient client, { SILC_LOG_DEBUG(("Closing connection %p", conn)); - /* If connection machine is not running, we just delete the connection */ - if (!silc_fsm_is_started(&conn->internal->fsm)) { - silc_packet_stream_destroy(conn->stream); - silc_client_del_connection(conn->client, conn); - return; - } - /* Signal to close connection */ conn->internal->status = SILC_CLIENT_CONN_DISCONNECTED; if (!conn->internal->disconnected) { diff --git a/lib/silcclient/client_connect.c b/lib/silcclient/client_connect.c index 06f6a713..57911639 100644 --- a/lib/silcclient/client_connect.c +++ b/lib/silcclient/client_connect.c @@ -267,6 +267,9 @@ static void silc_client_rekey_completion(SilcSKE ske, silc_ske_free_rekey_material(conn->internal->rekey); conn->internal->rekey = rekey; + silc_ske_free(conn->internal->ske); + conn->internal->ske = NULL; + SILC_LOG_DEBUG(("Rekey completed conn %p", conn)); /* Rekey done */ diff --git a/lib/silcclient/client_ftp.c b/lib/silcclient/client_ftp.c index 42e22d15..ead3a04e 100644 --- a/lib/silcclient/client_ftp.c +++ b/lib/silcclient/client_ftp.c @@ -967,7 +967,7 @@ SILC_FSM_STATE(silc_client_ftp) SilcClientFtpSession session; SilcClientID remote_id; SilcClientEntry remote_client; - SilcKeyAgreementPayload payload; + SilcKeyAgreementPayload payload = NULL; char *hostname; SilcUInt16 port; @@ -1079,6 +1079,8 @@ SILC_FSM_STATE(silc_client_ftp) } out: + if (payload) + silc_key_agreement_payload_free(payload); silc_packet_free(packet); return SILC_FSM_FINISH; } diff --git a/lib/silccore/silcpacket.c b/lib/silccore/silcpacket.c index 94fcffc7..661fbbe4 100644 --- a/lib/silccore/silcpacket.c +++ b/lib/silccore/silcpacket.c @@ -2633,11 +2633,7 @@ SilcStream silc_packet_stream_wrap(SilcPacketStream stream, } } else { /* Non-blocking mode */ - if (!silc_mutex_alloc(&pws->lock)) { - silc_free(pws); - return NULL; - } - + silc_mutex_alloc(&pws->lock); silc_list_init(pws->in_queue, struct SilcPacketStruct, next); } diff --git a/lib/silcutil/silcmutex.h b/lib/silcutil/silcmutex.h index 82a9da39..070a2e9a 100644 --- a/lib/silcutil/silcmutex.h +++ b/lib/silcutil/silcmutex.h @@ -71,7 +71,8 @@ typedef struct SilcRwLockStruct *SilcRwLock; * Allocates SILC Mutex object. The mutex object must be allocated * before it can be used. It is freed by the silc_mutex_free function. * This returns TRUE and allocated mutex in to the `mutex' and FALSE - * on error. + * on error. If threads support is not compiled in this returns FALSE, + * but should not be considered as an error. * ***/ SilcBool silc_mutex_alloc(SilcMutex *mutex); -- 2.24.0