[FFmpeg-devel,1/5] lavf/tls_openssl: disable obsolete locking code on OpenSSL 1.1 and later

Submitted by Rodger Combs on Jan. 18, 2019, 8:46 a.m.

Details

Message ID 20190118084604.82324-1-rodger.combs@gmail.com
State New
Headers show

Commit Message

Rodger Combs Jan. 18, 2019, 8:46 a.m.
These functions are now all no-ops and locking is handled internally.
This fixes a small memory leak on init.
---
 libavformat/tls_openssl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index 7ae71bdaf3..9dd53c6fc0 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -48,7 +48,7 @@  typedef struct TLSContext {
 #endif
 } TLSContext;
 
-#if HAVE_THREADS
+#if HAVE_THREADS && (OPENSSL_VERSION_NUMBER < 0x1010000fL)
 #include <openssl/crypto.h>
 pthread_mutex_t *openssl_mutexes;
 static void openssl_lock(int mode, int type, const char *file, int line)
@@ -72,7 +72,7 @@  int ff_openssl_init(void)
     if (!openssl_init) {
         SSL_library_init();
         SSL_load_error_strings();
-#if HAVE_THREADS
+#if HAVE_THREADS && (OPENSSL_VERSION_NUMBER < 0x1010000fL)
         if (!CRYPTO_get_locking_callback()) {
             int i;
             openssl_mutexes = av_malloc_array(sizeof(pthread_mutex_t), CRYPTO_num_locks());
@@ -101,7 +101,7 @@  void ff_openssl_deinit(void)
     ff_lock_avformat();
     openssl_init--;
     if (!openssl_init) {
-#if HAVE_THREADS
+#if HAVE_THREADS && (OPENSSL_VERSION_NUMBER < 0x1010000fL)
         if (CRYPTO_get_locking_callback() == openssl_lock) {
             int i;
             CRYPTO_set_locking_callback(NULL);