]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1828. [bug] isc_rwlock_init() failed to properly cleanup if it
authorMark Andrews <marka@isc.org>
Tue, 15 Mar 2005 02:03:11 +0000 (02:03 +0000)
committerMark Andrews <marka@isc.org>
Tue, 15 Mar 2005 02:03:11 +0000 (02:03 +0000)
                        encountered a error. [RT #13549]

CHANGES
lib/isc/rwlock.c

diff --git a/CHANGES b/CHANGES
index f11a430cf01a6a426fed8a26f3ef4454a7d7a50e..1426b9b6fd939a6e254d14dc579161ef29ea763c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+1828.  [bug]           isc_rwlock_init() failed to properly cleanup if it
+                       encountered a error. [RT #13549]
+
 1827.  [bug]           host: update usage message for '-a'. [RT #37116]
 
 1826.  [bug]           Missing DESTROYLOCK() in isc_mem_createx() on out
index 638c854faa267d4633a0201065e1b1f965878c25..887143910a935fb910a6cf2801d5625eee73a5ca 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: rwlock.c,v 1.37 2004/03/05 05:10:49 marka Exp $ */
+/* $Id: rwlock.c,v 1.38 2005/03/15 02:03:11 marka Exp $ */
 
 #include <config.h>
 
@@ -109,7 +109,9 @@ isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
                                 isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
                                                ISC_MSG_FAILED, "failed"),
                                 isc_result_totext(result));
-               return (ISC_R_UNEXPECTED);
+               result = ISC_R_UNEXPECTED;
+               goto destroy_lock;
+
        }
        result = isc_condition_init(&rwl->writeable);
        if (result != ISC_R_SUCCESS) {
@@ -118,12 +120,20 @@ isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
                                 isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
                                                ISC_MSG_FAILED, "failed"),
                                 isc_result_totext(result));
-               return (ISC_R_UNEXPECTED);
+               result = ISC_R_UNEXPECTED;
+               goto destroy_rcond;
        }
 
        rwl->magic = RWLOCK_MAGIC;
 
        return (ISC_R_SUCCESS);
+
+  destroy_rcond:
+       (void)isc_condition_destroy(&rwl->readable);
+  destroy_lock:
+       DESTROYLOCK(&rwl->lock);
+
+       return (result);
 }
 
 static isc_result_t