summaryrefslogtreecommitdiff
path: root/lib/ldb-samba
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2016-06-27 10:52:55 +1200
committerStefan Metzmacher <metze@samba.org>2016-07-28 10:06:12 +0200
commitcb6395c858001c6a807aa666860092024066a178 (patch)
tree9c4dc99f12fdce7f76ce985667e54157b218253d /lib/ldb-samba
parent1246904d41eebc3440636dd29a9dc9ba38b738f6 (diff)
downloadsamba-cb6395c858001c6a807aa666860092024066a178.tar.gz
lib/ldb-samba: Use ndr_push_struct_into_fixed_blob() in ldif_handlers.c
This avoids a number of pointless and pointlessly-large allocations in inner loops. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'lib/ldb-samba')
-rw-r--r--lib/ldb-samba/ldif_handlers.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/ldb-samba/ldif_handlers.c b/lib/ldb-samba/ldif_handlers.c
index c0972a4a6a7..510154d4aa0 100644
--- a/lib/ldb-samba/ldif_handlers.c
+++ b/lib/ldb-samba/ldif_handlers.c
@@ -91,8 +91,15 @@ static int ldif_read_objectSid(struct ldb_context *ldb, void *mem_ctx,
if (sid == NULL) {
return -1;
}
- ndr_err = ndr_push_struct_blob(out, mem_ctx, sid,
- (ndr_push_flags_fn_t)ndr_push_dom_sid);
+
+ *out = data_blob_talloc(mem_ctx, NULL,
+ ndr_size_dom_sid(sid, 0));
+ if (out->data == NULL) {
+ return -1;
+ }
+
+ ndr_err = ndr_push_struct_into_fixed_blob(out, sid,
+ (ndr_push_flags_fn_t)ndr_push_dom_sid);
talloc_free(sid);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
return -1;