diff options
| -rw-r--r-- | src/idevice.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/idevice.c b/src/idevice.c index 3b903c0..8cacf4c 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
| @@ -35,6 +35,7 @@ | |||
| 35 | 35 | ||
| 36 | #include <usbmuxd.h> | 36 | #include <usbmuxd.h> |
| 37 | #ifdef HAVE_OPENSSL | 37 | #ifdef HAVE_OPENSSL |
| 38 | #include <openssl/err.h> | ||
| 38 | #include <openssl/ssl.h> | 39 | #include <openssl/ssl.h> |
| 39 | #else | 40 | #else |
| 40 | #include <gnutls/gnutls.h> | 41 | #include <gnutls/gnutls.h> |
| @@ -83,14 +84,19 @@ static void internal_idevice_deinit(void) | |||
| 83 | { | 84 | { |
| 84 | #ifdef HAVE_OPENSSL | 85 | #ifdef HAVE_OPENSSL |
| 85 | int i; | 86 | int i; |
| 86 | if (!mutex_buf) | 87 | if (mutex_buf) { |
| 87 | return; | 88 | CRYPTO_set_id_callback(NULL); |
| 88 | CRYPTO_set_id_callback(NULL); | 89 | CRYPTO_set_locking_callback(NULL); |
| 89 | CRYPTO_set_locking_callback(NULL); | 90 | for (i = 0; i < CRYPTO_num_locks(); i++) |
| 90 | for (i = 0; i < CRYPTO_num_locks(); i++) | 91 | mutex_destroy(&mutex_buf[i]); |
| 91 | mutex_destroy(&mutex_buf[i]); | 92 | free(mutex_buf); |
| 92 | free(mutex_buf); | 93 | mutex_buf = NULL; |
| 93 | mutex_buf = NULL; | 94 | } |
| 95 | |||
| 96 | EVP_cleanup(); | ||
| 97 | CRYPTO_cleanup_all_ex_data(); | ||
| 98 | sk_SSL_COMP_free(SSL_COMP_get_compression_methods()); | ||
| 99 | ERR_remove_thread_state(NULL); | ||
| 94 | #else | 100 | #else |
| 95 | gnutls_global_deinit(); | 101 | gnutls_global_deinit(); |
| 96 | #endif | 102 | #endif |
| @@ -710,6 +716,8 @@ idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection) | |||
| 710 | ret = IDEVICE_E_SUCCESS; | 716 | ret = IDEVICE_E_SUCCESS; |
| 711 | debug_info("SSL mode enabled, cipher: %s", SSL_get_cipher(ssl)); | 717 | debug_info("SSL mode enabled, cipher: %s", SSL_get_cipher(ssl)); |
| 712 | } | 718 | } |
| 719 | /* required for proper multi-thread clean up to prevent leaks */ | ||
| 720 | ERR_remove_thread_state(NULL); | ||
| 713 | #else | 721 | #else |
| 714 | ssl_data_t ssl_data_loc = (ssl_data_t)malloc(sizeof(struct ssl_data_private)); | 722 | ssl_data_t ssl_data_loc = (ssl_data_t)malloc(sizeof(struct ssl_data_private)); |
| 715 | 723 | ||
