WHY??? Revert "ltdb_modify_internal..."
authorStefan Metzmacher <metze@samba.org>
Wed, 25 Sep 2013 08:50:17 +0000 (10:50 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 25 Sep 2013 08:50:17 +0000 (10:50 +0200)
This reverts commit fa0d28c34a62ac3b4e512fef3aa329b3951c20e7.

lib/ldb/ldb_tdb/ldb_tdb.c

index 14aa2153e8fce265ca84619b4bf3afcf7b0898a0..a8c6e97ec129590a0cf1349bcae5275fbef30a6c 100644 (file)
@@ -795,15 +795,8 @@ int ltdb_modify_internal(struct ldb_module *module,
                        }
 
                        /* Checks if element already exists */
-                       el2 = NULL;
                        idx = find_element(msg2, el->name);
-                       if (idx != -1) {
-                               el2 = &msg2->elements[idx];
-                               if (el2->num_values == 0) {
-                                       el2 = NULL;
-                               }
-                       }
-                       if (el == NULL) {
+                       if (idx == -1) {
                                if (ltdb_msg_add_element(ldb, msg2, el) != 0) {
                                        ret = LDB_ERR_OTHER;
                                        goto done;
@@ -814,6 +807,9 @@ int ltdb_modify_internal(struct ldb_module *module,
                                        goto done;
                                }
                        } else {
+                               j = (unsigned int) idx;
+                               el2 = &(msg2->elements[j]);
+
                                /* We cannot add another value on a existing one
                                   if the attribute is single-valued */
                                if (ldb_tdb_single_valued(a, el)) {