提交 dd50c005 编写于 作者: D Daniel P. Berrange

Fix leak of mutex attributes in POSIX threads impl

* src/util/threads-pthread.c: Fix mutex leak
上级 7020ffc0
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册