From 848010b5705eb6e11d1b9361c5a7243c9da4e886 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Fri, 26 Nov 2010 13:03:59 +0100 Subject: s4:objectclass LDB module - move the "mem_ctx" allocation to a better place It's only needed if we've a schema around. --- source4/dsdb/samdb/ldb_modules/objectclass.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'source4/dsdb') diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c index 66e6e393ea..edc9fabd5c 100644 --- a/source4/dsdb/samdb/ldb_modules/objectclass.c +++ b/source4/dsdb/samdb/ldb_modules/objectclass.c @@ -514,26 +514,24 @@ static int objectclass_do_add(struct oc_context *ac) } } - mem_ctx = talloc_new(ac); - if (mem_ctx == NULL) { - return ldb_module_oom(ac->module); - } - if (ac->schema != NULL) { objectclass_element = ldb_msg_find_element(msg, "objectClass"); if (!objectclass_element) { ldb_asprintf_errstring(ldb, "objectclass: Cannot add %s, no objectclass specified!", ldb_dn_get_linearized(msg->dn)); - talloc_free(mem_ctx); return LDB_ERR_OBJECT_CLASS_VIOLATION; } if (objectclass_element->num_values == 0) { ldb_asprintf_errstring(ldb, "objectclass: Cannot add %s, at least one (structural) objectclass has to be specified!", ldb_dn_get_linearized(msg->dn)); - talloc_free(mem_ctx); return LDB_ERR_CONSTRAINT_VIOLATION; } + mem_ctx = talloc_new(ac); + if (mem_ctx == NULL) { + return ldb_module_oom(ac->module); + } + /* Here we do now get the "objectClass" list from the * database. */ ret = objectclass_sort(ac->module, ac->schema, mem_ctx, @@ -594,6 +592,7 @@ static int objectclass_do_add(struct oc_context *ac) "objectclass: object class '%s' is LSA-specific, rejecting creation of '%s' over LDAP!", objectclass_name, ldb_dn_get_linearized(msg->dn)); + talloc_free(mem_ctx); return LDB_ERR_UNWILLING_TO_PERFORM; } -- cgit