diff options
author | Jeremy Allison <jra@samba.org> | 2007-04-30 02:39:34 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:19:49 -0500 |
commit | be8b0685a55700c6bce3681734800ec6434b0364 (patch) | |
tree | 8616d85686fb147d431eeea435233f45d5ee8d41 /source3/passdb | |
parent | 79de0ad9463a5cd64978beae37df79fbb4f74632 (diff) | |
download | samba-be8b0685a55700c6bce3681734800ec6434b0364.tar.gz samba-be8b0685a55700c6bce3681734800ec6434b0364.tar.bz2 samba-be8b0685a55700c6bce3681734800ec6434b0364.zip |
r22589: Make TALLOC_ARRAY consistent across all uses.
Jeremy.
(This used to be commit 8968808c3b5b0208cbad9ac92eaf948f2c546dd9)
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/lookup_sid.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c index b260d8ce57..2cef17725b 100644 --- a/source3/passdb/lookup_sid.c +++ b/source3/passdb/lookup_sid.c @@ -446,11 +446,16 @@ static BOOL lookup_rids(TALLOC_CTX *mem_ctx, const DOM_SID *domain_sid, { int i; - *names = TALLOC_ARRAY(mem_ctx, const char *, num_rids); - *types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_rids); + if (num_rids) { + *names = TALLOC_ARRAY(mem_ctx, const char *, num_rids); + *types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_rids); - if ((*names == NULL) || (*types == NULL)) { - return False; + if ((*names == NULL) || (*types == NULL)) { + return False; + } + } else { + *names = NULL; + *types = NULL; } if (sid_check_is_domain(domain_sid)) { @@ -687,10 +692,19 @@ NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, int num_sids, return NT_STATUS_NO_MEMORY; } - name_infos = TALLOC_ARRAY(mem_ctx, struct lsa_name_info, num_sids); + if (num_sids) { + name_infos = TALLOC_ARRAY(mem_ctx, struct lsa_name_info, num_sids); + if (name_infos == NULL) { + result = NT_STATUS_NO_MEMORY; + goto fail; + } + } else { + name_infos = NULL; + } + dom_infos = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_dom_info, MAX_REF_DOMAINS); - if ((name_infos == NULL) || (dom_infos == NULL)) { + if (dom_infos == NULL) { result = NT_STATUS_NO_MEMORY; goto fail; } @@ -824,9 +838,13 @@ NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, int num_sids, break; } - if (!(rids = TALLOC_ARRAY(tmp_ctx, uint32, dom->num_idxs))) { - result = NT_STATUS_NO_MEMORY; - goto fail; + if (dom->num_idxs) { + if (!(rids = TALLOC_ARRAY(tmp_ctx, uint32, dom->num_idxs))) { + result = NT_STATUS_NO_MEMORY; + goto fail; + } + } else { + rids = NULL; } for (j=0; j<dom->num_idxs; j++) { |