s4-dsdb: use ldb_msg_normalize() in ldb_msg_difference()
authorKamen Mazdrashki <kamenim@samba.org>
Fri, 16 Jul 2010 11:18:14 +0000 (14:18 +0300)
committerKamen Mazdrashki <kamenim@samba.org>
Fri, 16 Jul 2010 11:31:15 +0000 (14:31 +0300)
source4/lib/ldb/common/ldb_msg.c

index a6430046051af72c9cbda6e50bfeb0fa8a7f2d12..8cf2584413bc02af909ebbfd33bf024995df49e0 100644 (file)
@@ -705,15 +705,17 @@ int ldb_msg_difference(struct ldb_context *ldb,
        mod->num_elements = 0;
        mod->elements = NULL;
 
-       /* canonicalize msg2 so we have no repeated elements */
-       msg2 = ldb_msg_canonicalize(ldb, msg2);
-       if (msg2 == NULL) {
+       /*
+        * Canonicalize *msg2 so we have no repeated elements
+        * Resulting message is allocated in *mod's mem context,
+        * as we are going to move some elements from *msg2 to
+        * *mod object later
+        */
+       ldb_res = ldb_msg_normalize(ldb, mod, msg2, &msg2);
+       if (ldb_res != LDB_SUCCESS) {
                goto failed;
        }
 
-       /* steal msg2 into mod context as it is allocated in ldb's context */
-       talloc_steal(mod, msg2);
-
        /* look in msg2 to find elements that need to be added or modified */
        for (i=0;i<msg2->num_elements;i++) {
                el = ldb_msg_find_element(msg1, msg2->elements[i].name);