src/crypto.c: possible fix for memory leak related
[citadel.git] / webcit / src / crypto.c
index ae3e417c8c65d0946b39e1823e030090e7f0c09d..77ba8947c210847b98fe290cfa51835a99cfb323 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 /*@{*/
+#include "config.h"
 #ifdef HAVE_OPENSSL
 
 #include "webcit.h"
@@ -377,10 +378,16 @@ int starttls(int sock) {
  */
 void endtls(void)
 {
+       SSL_CTX *ctx = NULL;
+
        if (THREADSSL == NULL) return;
 
        lprintf(5, "Ending SSL/TLS\n");
        SSL_shutdown(THREADSSL);
+       ctx = SSL_get_SSL_CTX(THREADSSL);
+       if (ctx != NULL) {
+               SSL_CTX_free(ctx);
+       }
        SSL_free(THREADSSL);
        pthread_setspecific(ThreadSSL, NULL);
 }