From ebdf6e079b758aeb750201c4989706c43af2420e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 27 Jul 2016 10:26:56 +1200 Subject: [PATCH] ldb: Free empty index lists as talloc_realloc() fails in this case talloc_realloc() requires that we know the correct parent to do the 0 -> free behaviour and we do not have the correct parent here, list->dn may be a child of the module->idxptr cache. Signed-off-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- lib/ldb/ldb_tdb/ldb_index.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/ldb/ldb_tdb/ldb_index.c b/lib/ldb/ldb_tdb/ldb_index.c index 03ad44a1757..ede37f99d3d 100644 --- a/lib/ldb/ldb_tdb/ldb_index.c +++ b/lib/ldb/ldb_tdb/ldb_index.c @@ -1384,7 +1384,12 @@ int ltdb_index_del_value(struct ldb_module *module, struct ldb_dn *dn, memmove(&list->dn[j], &list->dn[j+1], sizeof(list->dn[0])*(list->count - (j+1))); } list->count--; - list->dn = talloc_realloc(list, list->dn, struct ldb_val, list->count); + if (list->count == 0) { + talloc_free(list->dn); + list->dn = NULL; + } else { + list->dn = talloc_realloc(list, list->dn, struct ldb_val, list->count); + } ret = ltdb_dn_list_store(module, dn_key, list); -- 2.11.4.GIT