summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/tools/ldbedit.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index f28964b06a..bb23f56377 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -67,16 +67,17 @@ static int modify_record(struct ldb_context *ldb,
struct ldb_message *msg2,
struct ldb_control **req_ctrls)
{
+ int ret;
struct ldb_message *mod;
- mod = ldb_msg_diff(ldb, msg1, msg2);
- if (mod == NULL) {
+ if (ldb_msg_difference(ldb, ldb, msg1, msg2, &mod) != LDB_SUCCESS) {
fprintf(stderr, "Failed to calculate message differences\n");
return -1;
}
- if (mod->num_elements == 0) {
- return 0;
+ ret = mod->num_elements;
+ if (ret == 0) {
+ goto done;
}
if (options->verbose > 0) {
@@ -86,10 +87,13 @@ static int modify_record(struct ldb_context *ldb,
if (ldb_modify_ctrl(ldb, mod, req_ctrls) != 0) {
fprintf(stderr, "failed to modify %s - %s\n",
ldb_dn_get_linearized(msg1->dn), ldb_errstring(ldb));
- return -1;
+ ret = -1;
+ goto done;
}
- return mod->num_elements;
+done:
+ talloc_free(mod);
+ return ret;
}
/*