summaryrefslogtreecommitdiff
path: root/src/lib/crypt_ops
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2019-09-20 11:27:05 +1000
committerteor <teor@torproject.org>2019-09-26 12:37:25 +1000
commitd1eab05834566f998721d3a16107767885711c57 (patch)
tree4224a8adc04fd130a8794f18e3bd8d54c82d87e8 /src/lib/crypt_ops
parent02840169d860384257042bdf6d7601c2bf48b47b (diff)
downloadtor-d1eab05834566f998721d3a16107767885711c57.tar.gz
tor-d1eab05834566f998721d3a16107767885711c57.zip
lock: Avoid some undefined behaviour when freeing mutexes.
Fixes bug 31736; bugfix on 0.0.7.
Diffstat (limited to 'src/lib/crypt_ops')
-rw-r--r--src/lib/crypt_ops/crypto_openssl_mgt.c4
1 files changed, 4 insertions, 0 deletions
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_;