summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-07-16 13:47:41 +0300
committerAndrew Bartlett <abartlet@samba.org>2010-07-19 17:33:34 +1000
commit48574ccc3f46a58940a06b524ff3be3c6da6b104 (patch)
tree29ac21f84fe097f26c7227fb370466dafab22a90 /source4/lib/ldb
parent3944c81d08177e7fa360b1925648686c729e2773 (diff)
downloadsamba-48574ccc3f46a58940a06b524ff3be3c6da6b104.tar.gz
samba-48574ccc3f46a58940a06b524ff3be3c6da6b104.tar.bz2
samba-48574ccc3f46a58940a06b524ff3be3c6da6b104.zip
s4-ldb: Use _ldb_msg_add_el() in ldb_msg_add()
Previous implementation was 'leaking' attribute name string, that is allocated by ldb_msg_add_empty() Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/common/ldb_msg.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c
index 5681d5228e..a2a1ba8110 100644
--- a/source4/lib/ldb/common/ldb_msg.c
+++ b/source4/lib/ldb/common/ldb_msg.c
@@ -187,15 +187,21 @@ int ldb_msg_add(struct ldb_message *msg,
const struct ldb_message_element *el,
int flags)
{
+ int ret;
+ struct ldb_message_element *el_new;
/* 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) != LDB_SUCCESS) {
- return LDB_ERR_OPERATIONS_ERROR;
+
+ ret = _ldb_msg_add_el(msg, &el_new);
+ if (ret != LDB_SUCCESS) {
+ return ret;
}
- msg->elements[msg->num_elements-1] = el_copy;
- msg->elements[msg->num_elements-1].flags = flags;
+ el_new->flags = flags;
+ el_new->name = el_copy.name;
+ el_new->num_values = el_copy.num_values;
+ el_new->values = el_copy.values;
return LDB_SUCCESS;
}