summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2010-11-26 13:03:59 +0100
committerMatthias Dieter Wallnöfer <mdw@samba.org>2010-11-26 13:10:00 +0100
commit848010b5705eb6e11d1b9361c5a7243c9da4e886 (patch)
tree7bd9f60f3e7e2e31110171d468272f3bfd9fd57f /source4/dsdb
parent7048ad11f518b88897a73fb5e0a46520b703a7d6 (diff)
downloadsamba-848010b5705eb6e11d1b9361c5a7243c9da4e886.tar.gz
samba-848010b5705eb6e11d1b9361c5a7243c9da4e886.tar.bz2
samba-848010b5705eb6e11d1b9361c5a7243c9da4e886.zip
s4:objectclass LDB module - move the "mem_ctx" allocation to a better place
It's only needed if we've a schema around.
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/ldb_modules/objectclass.c13
1 files changed, 6 insertions, 7 deletions
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;
}