From: Andrew Bartlett Date: Tue, 26 Jul 2016 12:20:27 +0000 (+1200) Subject: ldb: Prepare for adding flags to ltdb_search_dn1() to control memory allocation X-Git-Tag: ldb-1.1.27~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b465161aaaf79d62a68193f09e4409e363df434f;p=thirdparty%2Fsamba.git 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 --- 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; }