about summary refs log tree commit diff
diff options
context:
space:
mode:
authorjoboet <jonasboettiger@icloud.com>2022-10-19 00:32:33 +0200
committerjoboet <jonasboettiger@icloud.com>2022-11-06 15:32:59 +0100
commitb231835179e2c2fd830fe65e5701e139a2ac988f (patch)
treef7031cf50e6d0790d6f0af8b0cd7194bad7d0685
parent98815742cf2e914ee0d7142a02322cf939c47834 (diff)
downloadrust-b231835179e2c2fd830fe65e5701e139a2ac988f.tar.gz
rust-b231835179e2c2fd830fe65e5701e139a2ac988f.zip
std: fix double-free of mutex
-rw-r--r--library/std/src/sys/unix/locks/pthread_mutex.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/std/src/sys/unix/locks/pthread_mutex.rs b/library/std/src/sys/unix/locks/pthread_mutex.rs
index a1155a808aa..8a78bc1fd73 100644
--- a/library/std/src/sys/unix/locks/pthread_mutex.rs
+++ b/library/std/src/sys/unix/locks/pthread_mutex.rs
@@ -64,7 +64,7 @@ impl LazyInit for AllocatedMutex {
         // We're not allowed to pthread_mutex_destroy a locked mutex,
         // so check first if it's unlocked.
         if unsafe { libc::pthread_mutex_trylock(mutex.0.get()) == 0 } {
-            unsafe { libc::pthread_mutex_destroy(mutex.0.get()) };
+            unsafe { libc::pthread_mutex_unlock(mutex.0.get()) };
             drop(mutex);
         } else {
             // The mutex is locked. This happens if a MutexGuard is leaked.