]> git.sur5r.net Git - openldap/commitdiff
mdb_env_setup_locks: Plug mutexattr leak on error
authorHallvard Furuseth <hallvard@openldap.org>
Sun, 5 Jun 2016 21:42:44 +0000 (23:42 +0200)
committerHoward Chu <hyc@openldap.org>
Wed, 15 Jun 2016 10:41:14 +0000 (11:41 +0100)
libraries/liblmdb/mdb.c

index 0bdfef547ce1a87a429ec67f73b57205f9f4a250..1edc282b814ca220ca3b4e15a458b1e8320edcce 100644 (file)
@@ -4628,15 +4628,18 @@ mdb_env_setup_locks(MDB_env *env, char *lpath, int mode, int *excl)
                memset(env->me_txns->mti_rmutex, 0, sizeof(*env->me_txns->mti_rmutex));
                memset(env->me_txns->mti_wmutex, 0, sizeof(*env->me_txns->mti_wmutex));
 
-               if ((rc = pthread_mutexattr_init(&mattr))
-                       || (rc = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED))
+               if ((rc = pthread_mutexattr_init(&mattr)))
+                       goto fail;
+
+               rc = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
 #ifdef MDB_ROBUST_SUPPORTED
-                       || (rc = pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST))
+               if (!rc) rc = pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST);
 #endif
-                       || (rc = pthread_mutex_init(env->me_txns->mti_rmutex, &mattr))
-                       || (rc = pthread_mutex_init(env->me_txns->mti_wmutex, &mattr)))
-                       goto fail;
+               if (!rc) rc = pthread_mutex_init(env->me_txns->mti_rmutex, &mattr);
+               if (!rc) rc = pthread_mutex_init(env->me_txns->mti_wmutex, &mattr);
                pthread_mutexattr_destroy(&mattr);
+               if (rc)
+                       goto fail;
 #endif /* _WIN32 || MDB_USE_POSIX_SEM */
 
                env->me_txns->mti_magic = MDB_MAGIC;