From: Mark Andrews Date: Sun, 23 May 2004 11:05:21 +0000 (+0000) Subject: 1643. [bug] dns_db_closeversion() could leak memory / node X-Git-Tag: v9.2.3rc4^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c49c2f9f85d6312b42e6f836c15fdacb07daddee;p=thirdparty%2Fbind9.git 1643. [bug] dns_db_closeversion() could leak memory / node references. [RT #11163] --- diff --git a/CHANGES b/CHANGES index ddcfd85377b..eecb68f9fed 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +1643. [bug] dns_db_closeversion() could leak memory / node + references. [RT #11163] + --- 9.2.4rc4 released --- diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 305e75ee231..ec6c05b404d 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rbtdb.c,v 1.168.2.17 2004/04/15 01:38:07 marka Exp $ */ +/* $Id: rbtdb.c,v 1.168.2.18 2004/05/23 11:05:21 marka Exp $ */ /* * Principal Author: Bob Halley @@ -1003,9 +1003,13 @@ closeversion(dns_db_t *db, dns_dbversion_t **versionp, isc_boolean_t commit) { * isn't being used by anyone, we can clean * it up. */ - if (rbtdb->current_version->references == 0) + if (rbtdb->current_version->references == 0) { cleanup_version = rbtdb->current_version; + APPENDLIST(version->changed_list, + cleanup_version->changed_list, + link); + } /* * Become the current version. */ @@ -1018,6 +1022,7 @@ closeversion(dns_db_t *db, dns_dbversion_t **versionp, isc_boolean_t commit) { * We're rolling back this transaction. */ cleanup_list = version->changed_list; + ISC_LIST_INIT(version->changed_list); rollback = ISC_TRUE; cleanup_version = version; rbtdb->future_version = NULL; @@ -1038,6 +1043,7 @@ closeversion(dns_db_t *db, dns_dbversion_t **versionp, isc_boolean_t commit) { if (least_greater == NULL) least_greater = rbtdb->current_version; + INSIST(version->serial < least_greater->serial); /* * Is this the least open version? */ @@ -1058,16 +1064,19 @@ closeversion(dns_db_t *db, dns_dbversion_t **versionp, isc_boolean_t commit) { version->changed_list, link); } - } + } else if (version->serial == rbtdb->least_serial) + INSIST(EMPTY(version->changed_list)); UNLINK(rbtdb->open_versions, version, link); } } least_serial = rbtdb->least_serial; UNLOCK(&rbtdb->lock); - if (cleanup_version != NULL) + if (cleanup_version != NULL) { + INSIST(EMPTY(cleanup_version->changed_list)); isc_mem_put(rbtdb->common.mctx, cleanup_version, sizeof *cleanup_version); + } if (!EMPTY(cleanup_list)) { for (changed = HEAD(cleanup_list);