summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/common/ldb_msg.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c
index 69a2ab749b..e9c04df55a 100644
--- a/source4/lib/ldb/common/ldb_msg.c
+++ b/source4/lib/ldb/common/ldb_msg.c
@@ -162,11 +162,14 @@ int ldb_msg_add(struct ldb_message *msg,
const struct ldb_message_element *el,
int flags)
{
+ /* We have to copy this, just in case *el is a pointer into
+ * what ldb_msg_add_empty() is about to realloc() */
+ struct ldb_message_element el_copy = *el;
if (ldb_msg_add_empty(msg, el->name, flags, NULL) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
- msg->elements[msg->num_elements-1] = *el;
+ msg->elements[msg->num_elements-1] = el_copy;
msg->elements[msg->num_elements-1].flags = flags;
return LDB_SUCCESS;