From: Simon Ruderich Date: Fri, 11 Mar 2011 02:22:29 +0000 (+0100) Subject: src/connection.c: Fix memory leak in initialize_tls_session_*(). X-Git-Tag: 0.1~13 X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=12ffdb1962d587970f9666e758853f828d0b32cd;p=tlsproxy%2Ftlsproxy.git src/connection.c: Fix memory leak in initialize_tls_session_*(). --- diff --git a/src/connection.c b/src/connection.c index 2732f30..0f491e2 100644 --- a/src/connection.c +++ b/src/connection.c @@ -352,6 +352,7 @@ gnutls_certificate_allocate_credentials(): %s", LOG(LOG_ERROR, "initialize_tls_session_client(): can't read CA file: '%s'", PROXY_CA_FILE); + gnutls_certificate_free_credentials(*x509_cred); return -1; } /* And certificate for this website and proxy's private key. */ @@ -372,6 +373,7 @@ gnutls_certificate_allocate_credentials(): %s", "initialize_tls_session_client(): \ can't read server certificate ('%s') or key file ('%s'): %s", path, PROXY_KEY_FILE, gnutls_strerror(result)); + gnutls_certificate_free_credentials(*x509_cred); /* Could be a missing certificate. */ return -2; } @@ -383,6 +385,7 @@ can't read server certificate ('%s') or key file ('%s'): %s", LOG(LOG_ERROR, "initialize_tls_session_client(): gnutls_init(): %s", gnutls_strerror(result)); + gnutls_certificate_free_credentials(*x509_cred); return -1; } result = gnutls_priority_set(*session, tls_priority_cache); @@ -390,6 +393,8 @@ can't read server certificate ('%s') or key file ('%s'): %s", LOG(LOG_ERROR, "initialize_tls_session_client(): gnutls_priority_set(): %s", gnutls_strerror(result)); + gnutls_deinit(*session); + gnutls_certificate_free_credentials(*x509_cred); return -1; } result = gnutls_credentials_set(*session, @@ -398,6 +403,8 @@ can't read server certificate ('%s') or key file ('%s'): %s", LOG(LOG_ERROR, "initialize_tls_session_client(): gnutls_credentials_set(): %s", gnutls_strerror(result)); + gnutls_deinit(*session); + gnutls_certificate_free_credentials(*x509_cred); return -1; } @@ -424,6 +431,7 @@ gnutls_certificate_allocate_credentials(): %s", LOG(LOG_ERROR, "initialize_tls_session_server(): gnutls_init(): %s", gnutls_strerror(result)); + gnutls_certificate_free_credentials(*x509_cred); return -1; } gnutls_priority_set(*session, tls_priority_cache); @@ -431,6 +439,8 @@ gnutls_certificate_allocate_credentials(): %s", LOG(LOG_ERROR, "initialize_tls_session_server(): gnutls_priority_set(): %s", gnutls_strerror(result)); + gnutls_deinit(*session); + gnutls_certificate_free_credentials(*x509_cred); return -1; } result = gnutls_credentials_set(*session, @@ -439,6 +449,8 @@ gnutls_certificate_allocate_credentials(): %s", LOG(LOG_ERROR, "initialize_tls_session_server(): gnutls_credentials_set(): %s", gnutls_strerror(result)); + gnutls_deinit(*session); + gnutls_certificate_free_credentials(*x509_cred); return -1; }