]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap_r/tpool.c
Happy New Year!
[openldap] / libraries / libldap_r / tpool.c
index 12371db354531e82eaaaef419d91427ddf621e98..8c2b18749c7350de7c9df10c456b23ac55179073 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2014 The OpenLDAP Foundation.
+ * Copyright 1998-2016 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -214,14 +214,22 @@ ldap_pvt_thread_pool_init (
        if (pool == NULL) return(-1);
 
        rc = ldap_pvt_thread_mutex_init(&pool->ltp_mutex);
-       if (rc != 0)
+       if (rc != 0) {
+fail1:
+               LDAP_FREE(pool);
                return(rc);
+       }
        rc = ldap_pvt_thread_cond_init(&pool->ltp_cond);
-       if (rc != 0)
-               return(rc);
+       if (rc != 0) {
+fail2:
+               ldap_pvt_thread_mutex_destroy(&pool->ltp_mutex);
+               goto fail1;
+       }
        rc = ldap_pvt_thread_cond_init(&pool->ltp_pcond);
-       if (rc != 0)
-               return(rc);
+       if (rc != 0) {
+               ldap_pvt_thread_cond_destroy(&pool->ltp_cond);
+               goto fail2;
+       }
 
        ldap_int_has_thread_pool = 1;