From c7358d989034c9d936c04f2a7e4f89db252b798e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 22 Sep 2009 22:15:11 -0700 Subject: [PATCH] s4-ldb: fixed a memory leak --- source4/lib/ldb/ldb_tdb/ldb_index.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index 1acbc204f7f..66d70a9f47e 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -135,6 +135,7 @@ static int ltdb_convert_from_idxptr(struct ldb_module *module, struct ldb_messag return LDB_ERR_OPERATIONS_ERROR; } + talloc_free(el->values); *el = ptr->el; if (ptr_out) { @@ -163,7 +164,11 @@ static int ltdb_update_idxptr(struct ldb_module *module, TALLOC_CTX *mem_ctx, el->values = val2; el->num_values = 1; - el->values[0].data = talloc_memdup(el->values, &ptr, sizeof(ptr)); + if (strcmp(el->name, LTDB_IDXPTR) == 0) { + abort(); + } + + el->values[0].data = talloc_memdup(val2, &ptr, sizeof(ptr)); el->values[0].length = sizeof(ptr); /* update the name */ -- 2.34.1