From b465161aaaf79d62a68193f09e4409e363df434f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 27 Jul 2016 00:20:27 +1200 Subject: [PATCH] ldb: Prepare for adding flags to ltdb_search_dn1() to control memory allocation Because the memory layout will change in the next commit, we need to add a talloc_steal() of msg, which holds the memory on one big chunk. Signed-off-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- lib/ldb/ldb_tdb/ldb_index.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ldb/ldb_tdb/ldb_index.c b/lib/ldb/ldb_tdb/ldb_index.c index ede37f99d3d..e6bfb1b6239 100644 --- a/lib/ldb/ldb_tdb/ldb_index.c +++ b/lib/ldb/ldb_tdb/ldb_index.c @@ -192,10 +192,18 @@ normal_index: return LDB_SUCCESS; } - /* we avoid copying the strings by stealing the list */ + /* + * we avoid copying the strings by stealing the list. We have + * to steal msg onto el->values (which looks odd) because we + * asked for the memory to be allocated on msg, not on each + * value with LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC above + */ + talloc_steal(el->values, msg); list->dn = talloc_steal(list, el->values); list->count = el->num_values; + /* We don't need msg->elements any more */ + talloc_free(msg->elements); return LDB_SUCCESS; } -- 2.47.2