summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2010-06-17 15:27:50 +0200
committerMatthias Dieter Wallnöfer <mdw@samba.org>2010-06-18 10:03:09 +0200
commit955e1835ef14aa961127007014dfd93b464779eb (patch)
tree0a8849d4b1b96f546fe1ea38b3d3153da3e3a6a0
parent56e4822566743a42a3e20cc9dc969826969ba156 (diff)
downloadsamba-955e1835ef14aa961127007014dfd93b464779eb.tar.gz
samba-955e1835ef14aa961127007014dfd93b464779eb.tar.bz2
samba-955e1835ef14aa961127007014dfd93b464779eb.zip
s4:objectclass LDB module - move "mem_ctx" initialisation lower
Saves us some "talloc_free"s on error cases
-rw-r--r--source4/dsdb/samdb/ldb_modules/objectclass.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c
index 2df809701c..e5769a63dd 100644
--- a/source4/dsdb/samdb/ldb_modules/objectclass.c
+++ b/source4/dsdb/samdb/ldb_modules/objectclass.c
@@ -414,57 +414,52 @@ static int objectclass_do_add(struct oc_context *ac)
{
struct ldb_context *ldb;
struct ldb_request *add_req;
- char *value;
struct ldb_message_element *objectclass_element, *el;
struct ldb_message *msg;
TALLOC_CTX *mem_ctx;
struct class_list *sorted, *current;
- int ret;
+ const char *rdn_name = NULL;
+ char *value;
const struct dsdb_class *objectclass;
int32_t systemFlags = 0;
- const char *rdn_name = NULL;
+ int ret;
ldb = ldb_module_get_ctx(ac->module);
- mem_ctx = talloc_new(ac);
- if (mem_ctx == NULL) {
- ldb_oom(ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
msg = ldb_msg_copy_shallow(ac, ac->req->op.add.message);
/* Check if we have a valid parent - this check is needed since
* we don't get a LDB_ERR_NO_SUCH_OBJECT error. */
if (ac->search_res == NULL) {
if (ldb_dn_compare(ldb_get_root_basedn(ldb), msg->dn) == 0) {
- /* Allow the tree to be started */
-
- /* but don't keep any error string, it's meaningless */
+ /* Allow the tree to be started but don't keep any
+ * error strings - they're meaningless. */
ldb_set_errstring(ldb, NULL);
} else {
ldb_asprintf_errstring(ldb, "objectclass: Cannot add %s, parent does not exist!",
ldb_dn_get_linearized(msg->dn));
- talloc_free(mem_ctx);
return LDB_ERR_NO_SUCH_OBJECT;
}
} else {
-
/* Fix up the DN to be in the standard form, taking
* particular care to match the parent DN */
ret = fix_dn(msg,
ac->req->op.add.message->dn,
ac->search_res->message->dn,
&msg->dn);
-
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb, "objectclass: Could not munge DN %s into normal form",
ldb_dn_get_linearized(ac->req->op.add.message->dn));
- talloc_free(mem_ctx);
return ret;
}
+ }
+ mem_ctx = talloc_new(ac);
+ if (mem_ctx == NULL) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
}
+
if (ac->schema != NULL) {
/* This is now the objectClass list from the database */
objectclass_element = ldb_msg_find_element(msg, "objectClass");