]> git.lizzy.rs Git - rust.git/commitdiff
std: fix double-free of mutex
authorjoboet <jonasboettiger@icloud.com>
Tue, 18 Oct 2022 22:32:33 +0000 (00:32 +0200)
committerjoboet <jonasboettiger@icloud.com>
Sun, 6 Nov 2022 14:32:59 +0000 (15:32 +0100)
library/std/src/sys/unix/locks/pthread_mutex.rs

index a1155a808aaf461e4e5b2814e88276f402eae146..8a78bc1fd739904141deda9cafaba58b91a8f624 100644 (file)
@@ -64,7 +64,7 @@ fn destroy(mutex: Box<Self>) {
         // 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.