mdb_env_setup_locks: Plug mutexattr leak on error

ntdll
Hallvard Furuseth 9 years ago
parent 53a0fdf1be
commit c4c7833d24
  1. 14
      libraries/liblmdb/mdb.c

@ -4972,15 +4972,17 @@ 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_rmutex, 0, sizeof(*env->me_txns->mti_rmutex));
memset(env->me_txns->mti_wmutex, 0, sizeof(*env->me_txns->mti_wmutex)); memset(env->me_txns->mti_wmutex, 0, sizeof(*env->me_txns->mti_wmutex));
if ((rc = pthread_mutexattr_init(&mattr)) if ((rc = pthread_mutexattr_init(&mattr)) != 0)
|| (rc = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED)) goto fail;
rc = pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
#ifdef MDB_ROBUST_SUPPORTED #ifdef MDB_ROBUST_SUPPORTED
|| (rc = pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST)) if (!rc) rc = pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST);
#endif #endif
|| (rc = pthread_mutex_init(env->me_txns->mti_rmutex, &mattr)) if (!rc) rc = pthread_mutex_init(env->me_txns->mti_rmutex, &mattr);
|| (rc = pthread_mutex_init(env->me_txns->mti_wmutex, &mattr))) if (!rc) rc = pthread_mutex_init(env->me_txns->mti_wmutex, &mattr);
goto fail;
pthread_mutexattr_destroy(&mattr); pthread_mutexattr_destroy(&mattr);
if (rc)
goto fail;
#endif /* _WIN32 || ... */ #endif /* _WIN32 || ... */
env->me_txns->mti_magic = MDB_MAGIC; env->me_txns->mti_magic = MDB_MAGIC;

Loading…
Cancel
Save