From 3582250538e48053fa118a7ebda88b9a116f13b0 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 2 May 2024 16:45:59 +0200 Subject: [PATCH] lib:ldb: Use tdb_parse_record() in ldb_kv_dn_list_store() Signed-off-by: Andreas Schneider Reviewed-by: Volker Lendecke --- lib/ldb/ldb_key_value/ldb_kv_index.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/ldb/ldb_key_value/ldb_kv_index.c b/lib/ldb/ldb_key_value/ldb_kv_index.c index 51ac99b8f5b..6a265166e1d 100644 --- a/lib/ldb/ldb_key_value/ldb_kv_index.c +++ b/lib/ldb/ldb_key_value/ldb_kv_index.c @@ -841,6 +841,9 @@ static int ldb_kv_dn_list_store(struct ldb_module *module, int ret = LDB_SUCCESS; struct dn_list *list2 = NULL; struct ldb_kv_idxptr *idxptr = NULL; + struct ldb_dn_list_state state = { + .module = module, + }; key.dptr = discard_const_p(unsigned char, ldb_dn_get_linearized(dn)); if (key.dptr == NULL) { @@ -865,14 +868,16 @@ static int ldb_kv_dn_list_store(struct ldb_module *module, * the dn_list directly. * */ - rec = tdb_fetch(idxptr->itdb, key); - if (rec.dptr != NULL) { - list2 = ldb_kv_index_idxptr(module, rec); + ret = tdb_parse_record(idxptr->itdb, + key, + ldb_kv_index_idxptr_wrapper, + &state); + if (ret == 0) { + list2 = state.list; if (list2 == NULL) { free(rec.dptr); return LDB_ERR_OPERATIONS_ERROR; } - free(rec.dptr); /* Now put the updated pointer back in the cache */ if (list->dn == NULL) { list2->dn = NULL; -- 2.47.2