From 3e5235a568777b5103612069e413cabe37b83c2b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 2 Jan 2005 23:03:50 +0000 Subject: r4486: fixed some memory leaks in the new ldb code, by ensuring that memory is always allocated as a child of the right context (This used to be commit 1071712cf5951fa2e94f314bd7678cfa51b2dbcd) --- source4/lib/ldb/ldb_tdb/ldb_cache.c | 8 ++++---- source4/lib/ldb/ldb_tdb/ldb_pack.c | 2 +- source4/lib/ldb/ldb_tdb/ldb_search.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/lib/ldb/ldb_tdb') diff --git a/source4/lib/ldb/ldb_tdb/ldb_cache.c b/source4/lib/ldb/ldb_tdb/ldb_cache.c index e7420c5f7a..037403d81e 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_cache.c +++ b/source4/lib/ldb/ldb_tdb/ldb_cache.c @@ -205,14 +205,14 @@ int ltdb_increase_sequence_number(struct ldb_module *module) char *s = NULL; int ret; - s = talloc_asprintf(ldb, "%.0f", ltdb->sequence_number+1); - if (!s) { + msg = talloc_p(ltdb, struct ldb_message); + if (msg == NULL) { errno = ENOMEM; return -1; } - msg = talloc_p(ltdb, struct ldb_message); - if (msg == NULL) { + s = talloc_asprintf(msg, "%.0f", ltdb->sequence_number+1); + if (!s) { errno = ENOMEM; return -1; } diff --git a/source4/lib/ldb/ldb_tdb/ldb_pack.c b/source4/lib/ldb/ldb_tdb/ldb_pack.c index 4c1241d0bd..501728fac5 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_pack.c +++ b/source4/lib/ldb/ldb_tdb/ldb_pack.c @@ -199,7 +199,7 @@ int ltdb_unpack_data(struct ldb_module *module, goto failed; } - message->elements = talloc_array_p(ldb, struct ldb_message_element, message->num_elements); + message->elements = talloc_array_p(message, struct ldb_message_element, message->num_elements); if (!message->elements) { errno = ENOMEM; goto failed; diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c index 720188b74c..295c9578cc 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_search.c +++ b/source4/lib/ldb/ldb_tdb/ldb_search.c @@ -306,7 +306,7 @@ int ltdb_search_dn(struct ldb_module *module, char *dn, return -1; } - (*res)[0] = msg2; + (*res)[0] = talloc_steal(*res, msg2); (*res)[1] = NULL; return 1; @@ -341,7 +341,7 @@ int ltdb_add_attr_results(struct ldb_module *module, struct ldb_message *msg, (*res) = res2; - (*res)[*count] = msg2; + (*res)[*count] = talloc_steal(*res, msg2); (*res)[(*count)+1] = NULL; (*count)++; -- cgit