From: Petr Usoltsev Date: Tue, 3 Mar 2026 07:31:18 +0000 (+0800) Subject: lib:ldb: Fix memory leaks in ldb_kv_index.c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b3e4c2a104d351269d2063eb123481d1fda98a4;p=thirdparty%2Fsamba.git lib:ldb: Fix memory leaks in ldb_kv_index.c The "rec" variable is allocated within the long-lived LDB memory context, meaning it persists until the module is unloaded. Previously, this resource was only freed upon the successful execution of ldb_dn_compare(). If ldb_dn_compare fails, the allocated memory is leaked. This patch ensures that the memory is properly released regardless of the function's return status. Signed-off-by: Petr Usoltsev Reviewed-by: Douglas Bagnall Reviewed-by: Jennifer Sutton Reviewed-by: Anoop C S Autobuild-User(master): Anoop C S Autobuild-Date(master): Tue Jul 14 06:18:36 UTC 2026 on atb-devel-224 --- diff --git a/lib/ldb/ldb_key_value/ldb_kv_index.c b/lib/ldb/ldb_key_value/ldb_kv_index.c index 7f5361fe63f..9300d749f41 100644 --- a/lib/ldb/ldb_key_value/ldb_kv_index.c +++ b/lib/ldb/ldb_key_value/ldb_kv_index.c @@ -706,6 +706,7 @@ int ldb_kv_key_dn_from_idx(struct ldb_module *module, TALLOC_FREE(rec); break; } + TALLOC_FREE(rec); } /* @@ -2874,6 +2875,7 @@ static int ldb_kv_index_add1(struct ldb_module *module, TALLOC_FREE(list); return LDB_ERR_CONSTRAINT_VIOLATION; } + TALLOC_FREE(rec); } }