From 1e6fee4185b726e532c98e0feec1121d59f734c5 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 16 Mar 2010 14:41:51 +1100 Subject: [PATCH] s4:dsdb Add a memory context for dsdb_get_schema() When specified, we talloc_reference onto this context to ensure that pointers found in it are valid for the life of the objects they are placed into. (Such as the string form of LDAP attributes). Andrew Bartlett --- source4/dsdb/schema/schema_set.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index 305a0d94f32..e8fe7c4c650 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -413,9 +413,11 @@ int dsdb_set_global_schema(struct ldb_context *ldb) /** * Find the schema object for this ldb + * + * If reference_ctx is not NULL, then talloc_reference onto that context */ -struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb) +struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb, TALLOC_CTX *reference_ctx) { const void *p; struct dsdb_schema *schema; @@ -431,7 +433,11 @@ struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb) return NULL; } - return schema; + if (!reference_ctx) { + return schema; + } else { + return talloc_reference(reference_ctx, schema); + } } /** @@ -440,7 +446,7 @@ struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb) void dsdb_make_schema_global(struct ldb_context *ldb) { - struct dsdb_schema *schema = dsdb_get_schema(ldb); + struct dsdb_schema *schema = dsdb_get_schema(ldb, NULL); if (!schema) { return; } -- 2.34.1