summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-01-31 10:03:44 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:51:39 -0500
commitf9316daa4697bea13d2795c95a1486119de56e67 (patch)
treef135ac706db2523fcf2da4440600aaa6420a032a /source4/lib
parent60f8666ae88c5a03b0da58acb94015337442e18b (diff)
downloadsamba-f9316daa4697bea13d2795c95a1486119de56e67.tar.gz
samba-f9316daa4697bea13d2795c95a1486119de56e67.tar.bz2
samba-f9316daa4697bea13d2795c95a1486119de56e67.zip
r13256: Free temporary memory on error cases, and try to clean up what's left
earlier. Move gendb_search() to use talloc_vasprintf() and steal only the parts actually being used for the results. Andrew Bartlett (This used to be commit 53efb3e3e980c768e0aee216ccd8dc3e14707246)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/gendb.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/source4/lib/gendb.c b/source4/lib/gendb.c
index 7326975c1a..0b3361a2c5 100644
--- a/source4/lib/gendb.c
+++ b/source4/lib/gendb.c
@@ -42,7 +42,7 @@ int gendb_search_v(struct ldb_context *ldb,
int ret;
if (format) {
- vasprintf(&expr, format, ap);
+ expr = talloc_vasprintf(mem_ctx, format, ap);
if (expr == NULL) {
return -1;
}
@@ -55,7 +55,7 @@ int gendb_search_v(struct ldb_context *ldb,
ret = ldb_search(ldb, basedn, scope, expr, attrs, &res);
if (ret == LDB_SUCCESS) {
- talloc_steal(mem_ctx, res);
+ talloc_steal(mem_ctx, res->msgs);
DEBUG(4,("gendb_search_v: %s %s -> %d\n",
basedn?ldb_dn_linearize(mem_ctx,basedn):"NULL",
@@ -63,13 +63,13 @@ int gendb_search_v(struct ldb_context *ldb,
ret = res->count;
*msgs = res->msgs;
-
+ talloc_free(res);
} else {
DEBUG(4,("gendb_search_v: search failed: %s", ldb_errstring(ldb)));
ret = -1;
}
- free(expr);
+ talloc_free(expr);
return ret;
}