]> ruderich.org/simon Gitweb - tlsproxy/tlsproxy.git/commitdiff
src/connection.c: Fix memory leak in initialize_tls_session_*().
authorSimon Ruderich <simon@ruderich.org>
Fri, 11 Mar 2011 02:22:29 +0000 (03:22 +0100)
committerSimon Ruderich <simon@ruderich.org>
Fri, 11 Mar 2011 02:22:29 +0000 (03:22 +0100)
src/connection.c

index 2732f30caa9b700e3d6664262312c14a46afd8d5..0f491e2011c0447adbcd2dbf6c7190c38c0ea674 100644 (file)
@@ -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;
     }