diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/ldb/common/ldb_msg.c | 12 | ||||
-rw-r--r-- | source4/lib/ldb/pyldb.c | 4 |
2 files changed, 13 insertions, 3 deletions
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c index 702978a361..929f24cd88 100644 --- a/source4/lib/ldb/common/ldb_msg.c +++ b/source4/lib/ldb/common/ldb_msg.c @@ -560,6 +560,9 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, unsigned int i; mod = ldb_msg_new(ldb); + if (mod == NULL) { + return NULL; + } mod->dn = msg1->dn; mod->num_elements = 0; @@ -567,6 +570,7 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, msg2 = ldb_msg_canonicalize(ldb, msg2); if (msg2 == NULL) { + talloc_free(mod); return NULL; } @@ -581,7 +585,8 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, if (ldb_msg_add(mod, &msg2->elements[i], - el?LDB_FLAG_MOD_REPLACE:LDB_FLAG_MOD_ADD) != 0) { + el?LDB_FLAG_MOD_REPLACE:LDB_FLAG_MOD_ADD) != LDB_SUCCESS) { + talloc_free(mod); return NULL; } } @@ -589,10 +594,11 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, /* look in msg1 to find elements that need to be deleted */ for (i=0;i<msg1->num_elements;i++) { el = ldb_msg_find_element(msg2, msg1->elements[i].name); - if (!el) { + if (el == NULL) { if (ldb_msg_add_empty(mod, msg1->elements[i].name, - LDB_FLAG_MOD_DELETE, NULL) != 0) { + LDB_FLAG_MOD_DELETE, NULL) != LDB_SUCCESS) { + talloc_free(mod); return NULL; } } diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index 0fe4da9887..0dac61b8b7 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -956,6 +956,10 @@ static PyObject *py_ldb_msg_diff(PyLdbObject *self, PyObject *args) } diff = ldb_msg_diff(PyLdb_AsLdbContext(self), PyLdbMessage_AsMessage(py_msg_old), PyLdbMessage_AsMessage(py_msg_new)); + if (!diff) { + PyErr_SetString(PyExc_KeyError, "Failed to generate the Ldb Message diff"); + return NULL; + } py_ret = PyLdbMessage_FromMessage(diff); |