svn commit: samba r17398 - in
branches/SAMBA_4_0/source/lib/ldb/common: .
idra at samba.org
idra at samba.org
Fri Aug 4 12:05:47 GMT 2006
Author: idra
Date: 2006-08-04 12:05:46 +0000 (Fri, 04 Aug 2006)
New Revision: 17398
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17398
Log:
avoid a memleak when we are returned 0 results and make a more creative use of memory contexts
Modified:
branches/SAMBA_4_0/source/lib/ldb/common/ldb_modules.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_modules.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb_modules.c 2006-08-04 10:27:14 UTC (rev 17397)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_modules.c 2006-08-04 12:05:46 UTC (rev 17398)
@@ -261,17 +261,17 @@
if ((modules == NULL) && (strcmp("ldap", ldb->modules->ops->name) != 0)) {
int ret;
const char * const attrs[] = { "@LIST" , NULL};
- struct ldb_result *res;
- struct ldb_dn *mods;
+ struct ldb_result *res = NULL;
+ struct ldb_dn *mods_dn;
- mods = ldb_dn_explode(mem_ctx, "@MODULES");
- if (mods == NULL) {
+ mods_dn = ldb_dn_explode(mem_ctx, "@MODULES");
+ if (mods_dn == NULL) {
talloc_free(mem_ctx);
return -1;
}
- ret = ldb_search(ldb, mods, LDB_SCOPE_BASE, "", attrs, &res);
- talloc_free(mods);
+ ret = ldb_search(ldb, mods_dn, LDB_SCOPE_BASE, "", attrs, &res);
+ if (res) talloc_steal(mods_dn, res);
if (ret == LDB_SUCCESS && (res->count == 0 || res->msgs[0]->num_elements == 0)) {
ldb_debug(ldb, LDB_DEBUG_TRACE, "no modules required by the db\n");
} else {
@@ -282,7 +282,6 @@
}
if (res->count > 1) {
ldb_debug(ldb, LDB_DEBUG_FATAL, "Too many records found (%d), bailing out\n", res->count);
- talloc_free(res);
talloc_free(mem_ctx);
return -1;
}
@@ -290,8 +289,9 @@
modules = ldb_modules_list_from_string(ldb, mem_ctx,
(const char *)res->msgs[0]->elements[0].values[0].data);
- talloc_free(res);
}
+
+ talloc_free(mods_dn);
}
if (modules != NULL) {
More information about the samba-cvs
mailing list