s4:objectclass LDB module - objectclass modify op. - remove superflous "talloc_strdup"
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Wed, 12 Oct 2011 18:17:33 +0000 (20:17 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Thu, 27 Oct 2011 16:52:29 +0000 (18:52 +0200)
We are adding strings embedded in the schema structure which is basically
global and lives longer than the request - hence no duplication needed.

Reviewed-by: abartlet
source4/dsdb/samdb/ldb_modules/objectclass.c

index c854d30cf1efb58cb1fde5ac716980fd968b9ea0..89dd6efd8a0c79cb8d519078aea62177aca57f02 100644 (file)
@@ -985,7 +985,6 @@ static int objectclass_do_mod(struct oc_context *ac)
 {
        struct ldb_context *ldb;
        struct ldb_request *mod_req;
-       char *value;
        struct ldb_message_element *oc_el_entry, *oc_el_change;
        struct ldb_val *vals;
        struct ldb_message *msg;
@@ -1146,13 +1145,10 @@ static int objectclass_do_mod(struct oc_context *ac)
 
                /* Move from the linked list back into an ldb msg */
                for (current = sorted; current; current = current->next) {
-                       value = talloc_strdup(msg,
-                                             current->objectclass->lDAPDisplayName);
-                       if (value == NULL) {
-                               talloc_free(mem_ctx);
-                               return ldb_module_oom(ac->module);
-                       }
-                       ret = ldb_msg_add_string(msg, "objectClass", value);
+                       const char *objectclass_name = current->objectclass->lDAPDisplayName;
+
+                       ret = ldb_msg_add_string(msg, "objectClass",
+                                                objectclass_name);
                        if (ret != LDB_SUCCESS) {
                                ldb_set_errstring(ldb,
                                                  "objectclass: could not re-add sorted objectclasses!");