From d1eab05834566f998721d3a16107767885711c57 Mon Sep 17 00:00:00 2001 From: teor Date: Fri, 20 Sep 2019 11:27:05 +1000 Subject: lock: Avoid some undefined behaviour when freeing mutexes. Fixes bug 31736; bugfix on 0.0.7. --- src/lib/crypt_ops/crypto_openssl_mgt.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/lib/crypt_ops') diff --git a/src/lib/crypt_ops/crypto_openssl_mgt.c b/src/lib/crypt_ops/crypto_openssl_mgt.c index c97815f9a4..a245ef3810 100644 --- a/src/lib/crypt_ops/crypto_openssl_mgt.c +++ b/src/lib/crypt_ops/crypto_openssl_mgt.c @@ -176,6 +176,10 @@ crypto_openssl_free_all(void) tor_free(crypto_openssl_version_str); tor_free(crypto_openssl_header_version_str); + /* Destroying a locked mutex is undefined behaviour. This mutex may be + * locked, because multiple threads can access it. But we need to destroy + * it, otherwise re-initialisation will trigger undefined behaviour. + * See #31735 for details. */ #ifndef NEW_THREAD_API if (n_openssl_mutexes_) { int n = n_openssl_mutexes_; -- cgit v1.2.3-54-g00ecf