mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
Fix leak of mutex attributes in POSIX threads impl
* src/util/threads-pthread.c: Fix mutex leak
This commit is contained in:
parent
7020ffc0ed
commit
dd50c0054c
@ -47,7 +47,9 @@ int virMutexInit(virMutexPtr m)
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
|
||||
if ((ret = pthread_mutex_init(&m->lock, &attr)) != 0) {
|
||||
ret = pthread_mutex_init(&m->lock, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
if (ret != 0) {
|
||||
errno = ret;
|
||||
return -1;
|
||||
}
|
||||
@ -60,7 +62,9 @@ int virMutexInitRecursive(virMutexPtr m)
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
if ((ret = pthread_mutex_init(&m->lock, &attr)) != 0) {
|
||||
ret = pthread_mutex_init(&m->lock, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
if (ret != 0) {
|
||||
errno = ret;
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user