diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2012-11-11 18:22:39 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2012-11-11 18:22:39 +0000 |
commit | 2fb1262a8200ec05d1b3334103fb7182dc2b2fa7 (patch) | |
tree | 795442eded151c13c061ecc17a49239d57b015ba | |
parent | 1388d303ba0d2097ff745d4a17192195cebbd349 (diff) |
Tiny cleanup. Fixing some memory leaks (why did I not notice so far that
those free()s were commented out?).
-rw-r--r-- | lib/ssl_gnutls.c | 18 | ||||
-rw-r--r-- | protocols/twitter/twitter_lib.c | 8 |
2 files changed, 12 insertions, 14 deletions
diff --git a/lib/ssl_gnutls.c b/lib/ssl_gnutls.c index 93601ba6..987d78cb 100644 --- a/lib/ssl_gnutls.c +++ b/lib/ssl_gnutls.c @@ -37,7 +37,7 @@ int ssl_errno = 0; static gboolean initialized = FALSE; -gnutls_certificate_credentials xcred; +gnutls_certificate_credentials_t xcred; #include <limits.h> @@ -59,7 +59,7 @@ struct scd char *hostname; gboolean verify; - gnutls_session session; + gnutls_session_t session; }; static gboolean ssl_connected( gpointer data, gint source, b_input_condition cond ); @@ -131,7 +131,7 @@ void *ssl_starttls( int fd, char *hostname, gboolean verify, ssl_input_function conn->func = func; conn->data = data; conn->inpa = -1; - conn->hostname = hostname; + conn->hostname = g_strdup( hostname ); /* For now, SSL verification is globally enabled by setting the cafile setting in bitlbee.conf. Commented out by default because probably @@ -168,9 +168,9 @@ static int verify_certificate_callback( gnutls_session_t session ) int gnutlsret; int verifyret = 0; gnutls_x509_crt_t cert; - const char *hostname; + struct scd *conn; - hostname = gnutls_session_get_ptr( session ); + conn = gnutls_session_get_ptr( session ); gnutlsret = gnutls_certificate_verify_peers2( session, &status ); if( gnutlsret < 0 ) @@ -208,7 +208,7 @@ static int verify_certificate_callback( gnutls_session_t session ) if( cert_list == NULL || gnutls_x509_crt_import( cert, &cert_list[0], GNUTLS_X509_FMT_DER ) < 0 ) return VERIFY_CERT_ERROR; - if( !gnutls_x509_crt_check_hostname( cert, hostname ) ) + if( !gnutls_x509_crt_check_hostname( cert, conn->hostname ) ) { verifyret |= VERIFY_CERT_INVALID; verifyret |= VERIFY_CERT_WRONG_HOSTNAME; @@ -264,8 +264,7 @@ static gboolean ssl_connected( gpointer data, gint source, b_input_condition con ssl_init(); gnutls_init( &conn->session, GNUTLS_CLIENT ); - if( conn->verify ) - gnutls_session_set_ptr( conn->session, (void *) conn->hostname ); + gnutls_session_set_ptr( conn->session, (void *) conn ); #if GNUTLS_VERSION_NUMBER < 0x020c00 gnutls_transport_set_lowat( conn->session, 0 ); #endif @@ -273,7 +272,7 @@ static gboolean ssl_connected( gpointer data, gint source, b_input_condition con gnutls_credentials_set( conn->session, GNUTLS_CRD_CERTIFICATE, xcred ); sock_make_nonblocking( conn->fd ); - gnutls_transport_set_ptr( conn->session, (gnutls_transport_ptr) GNUTLS_STUPID_CAST conn->fd ); + gnutls_transport_set_ptr( conn->session, (gnutls_transport_ptr_t) GNUTLS_STUPID_CAST conn->fd ); return ssl_handshake( data, source, cond ); } @@ -399,6 +398,7 @@ void ssl_disconnect( void *conn_ ) if( conn->session ) gnutls_deinit( conn->session ); + g_free( conn->hostname ); g_free( conn ); } diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c index 3e5da854..ee19786a 100644 --- a/protocols/twitter/twitter_lib.c +++ b/protocols/twitter/twitter_lib.c @@ -957,9 +957,7 @@ static void twitter_get_mentions(struct im_connection *ic, gint64 next_cursor) } g_free(args[1]); - if (td->timeline_id) { - g_free(args[5]); - } + g_free(args[5]); } /** @@ -985,7 +983,7 @@ static void twitter_http_get_home_timeline(struct http_request *req) if (!(parsed = twitter_parse_response(ic, req))) goto end; twitter_xt_get_status_list(ic, parsed, txl); -// json_value_free(parsed); + json_value_free(parsed); td->home_timeline_obj = txl; @@ -1021,7 +1019,7 @@ static void twitter_http_get_mentions(struct http_request *req) if (!(parsed = twitter_parse_response(ic, req))) goto end; twitter_xt_get_status_list(ic, parsed, txl); -// json_value_free(parsed); + json_value_free(parsed); td->mentions_obj = txl; |