ltdb_modify_internal...
authorStefan Metzmacher <metze@samba.org>
Sun, 22 Sep 2013 21:39:49 +0000 (23:39 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 25 Sep 2013 08:49:23 +0000 (10:49 +0200)
lib/ldb/ldb_tdb/ldb_tdb.c

index a8c6e97ec129590a0cf1349bcae5275fbef30a6c..14aa2153e8fce265ca84619b4bf3afcf7b0898a0 100644 (file)
@@ -795,8 +795,15 @@ int ltdb_modify_internal(struct ldb_module *module,
                        }
 
                        /* Checks if element already exists */
+                       el2 = NULL;
                        idx = find_element(msg2, el->name);
-                       if (idx == -1) {
+                       if (idx != -1) {
+                               el2 = &msg2->elements[idx];
+                               if (el2->num_values == 0) {
+                                       el2 = NULL;
+                               }
+                       }
+                       if (el == NULL) {
                                if (ltdb_msg_add_element(ldb, msg2, el) != 0) {
                                        ret = LDB_ERR_OTHER;
                                        goto done;
@@ -807,9 +814,6 @@ 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)) {