winbindd: make use of talloc_zero_array() in wb_lookupsids*()
authorStefan Metzmacher <metze@samba.org>
Tue, 23 Jan 2018 22:52:37 +0000 (23:52 +0100)
committerRalph Boehme <slow@samba.org>
Wed, 21 Feb 2018 13:19:17 +0000 (14:19 +0100)
It just feels better for such a complex function.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13281

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/winbindd/wb_lookupsids.c

index bd90c43bbe9c51615c15186c16e2956fb806524c..af02a0c9547b7124a54ca93a5285054e67fbc348 100644 (file)
@@ -124,7 +124,7 @@ struct tevent_req *wb_lookupsids_send(TALLOC_CTX *mem_ctx,
        state->sids = sids;
        state->num_sids = num_sids;
 
-       state->single_sids = talloc_array(state, uint32_t, num_sids);
+       state->single_sids = talloc_zero_array(state, uint32_t, num_sids);
        if (tevent_req_nomem(state->single_sids, req)) {
                return tevent_req_post(req, ev);
        }
@@ -133,7 +133,7 @@ struct tevent_req *wb_lookupsids_send(TALLOC_CTX *mem_ctx,
        if (tevent_req_nomem(state->res_domains, req)) {
                return tevent_req_post(req, ev);
        }
-       state->res_domains->domains = talloc_array(
+       state->res_domains->domains = talloc_zero_array(
                state->res_domains, struct lsa_DomainInfo, num_sids);
        if (tevent_req_nomem(state->res_domains->domains, req)) {
                return tevent_req_post(req, ev);
@@ -143,7 +143,7 @@ struct tevent_req *wb_lookupsids_send(TALLOC_CTX *mem_ctx,
        if (tevent_req_nomem(state->res_names, req)) {
                return tevent_req_post(req, ev);
        }
-       state->res_names->names = talloc_array(
+       state->res_names->names = talloc_zero_array(
                state->res_names, struct lsa_TranslatedName, num_sids);
        if (tevent_req_nomem(state->res_names->names, req)) {
                return tevent_req_post(req, ev);
@@ -371,13 +371,13 @@ static struct wb_lookupsids_domain *wb_lookupsids_get_domain(
        domain = &domains[num_domains];
        domain->domain = wb_domain;
 
-       domain->sids.sids = talloc_array(domains, struct lsa_SidPtr, num_sids);
+       domain->sids.sids = talloc_zero_array(domains, struct lsa_SidPtr, num_sids);
        if (domains->sids.sids == NULL) {
                goto fail;
        }
        domain->sids.num_sids = 0;
 
-       domain->sid_indexes = talloc_array(domains, uint32_t, num_sids);
+       domain->sid_indexes = talloc_zero_array(domains, uint32_t, num_sids);
        if (domain->sid_indexes == NULL) {
                TALLOC_FREE(domain->sids.sids);
                goto fail;