}
/* 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;
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)) {