summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2008-08-27 21:05:44 +0000
committerRich Megginson <rmeggins@redhat.com>2008-08-27 21:05:44 +0000
commitb621e8594f18242a6f9b45a4203b4a84a9c9829a (patch)
tree6bcd974911fa46ae3df68db3030ca86dd7521ca0
parentcb3c82e267ef5d9ae6161d4ab06f406e482dd9ad (diff)
downloadds-b621e8594f18242a6f9b45a4203b4a84a9c9829a.tar.gz
ds-b621e8594f18242a6f9b45a4203b4a84a9c9829a.tar.xz
ds-b621e8594f18242a6f9b45a4203b4a84a9c9829a.zip
Resolves: bug 458677
Bug Description: Memory leaks in index code doing indexed & range & matching rule searches Reviewed by: nkinder (Thanks!) Branch: HEAD Fix Description: This leak occurs when doing ranged, indexed searches. The code calls index2prefix to get the index prefix. In the case of a matching rule search, this prefix is allocated. The function free_prefix was not being called in all cases. Platforms tested: RHEL5, Fedora 8 Flag Day: no Doc impact: no QA impact: should be covered by regular nightly and manual testing New Tests integrated into TET: none
-rw-r--r--ldap/servers/slapd/back-ldbm/index.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index 49c8eda2..d7dc0b79 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -1047,7 +1047,7 @@ index_range_read(
DBT cur_key = {0};
DBT data = {0} ;
IDList *idl= NULL;
- char *prefix;
+ char *prefix = NULL;
char *realbuf, *nextrealbuf;
size_t reallen, nextreallen;
size_t plen;
@@ -1100,10 +1100,14 @@ index_range_read(
LDAPDebug( LDAP_DEBUG_ANY,
"<= index_range_read(%s,%s) NULL (operator %i)\n",
type, prefix, operator );
+ free_prefix(prefix);
return( NULL );
}
ainfo_get( be, type, &ai );
- if (ai == NULL) return NULL;
+ if (ai == NULL) {
+ free_prefix(prefix);
+ return NULL;
+ }
LDAPDebug( LDAP_DEBUG_ARGS, " indextype: \"%s\" indexmask: 0x%x\n",
indextype, ai->ai_indexmask, 0 );
if ( !is_indexed( indextype, ai->ai_indexmask, ai->ai_index_rules )) {
@@ -1111,12 +1115,14 @@ index_range_read(
LDAPDebug( LDAP_DEBUG_TRACE,
"<= index_range_read(%s,%s) %lu candidates (allids)\n",
type, prefix, (u_long)IDL_NIDS(idl) );
+ free_prefix(prefix);
return( idl );
}
if ( (*err = dblayer_get_index_file( be, ai, &db, DBOPEN_CREATE )) != 0 ) {
LDAPDebug( LDAP_DEBUG_ANY,
"<= index_range_read(%s,%s) NULL (could not open index file)\n",
type, prefix, 0 );
+ free_prefix(prefix);
return( NULL ); /* why not allids? */
}
if (NULL != txn) {
@@ -1130,6 +1136,7 @@ index_range_read(
"<= index_range_read(%s,%s) NULL: db->cursor() == %i\n",
type, prefix, *err );
dblayer_release_index_file( be, ai, db );
+ free_prefix(prefix);
return( NULL ); /* why not allids? */
}
@@ -1377,6 +1384,7 @@ index_range_read(
}
#endif
error:
+ free_prefix(prefix);
DBT_FREE_PAYLOAD(cur_key);
DBT_FREE_PAYLOAD(upperkey);