From be8b0685a55700c6bce3681734800ec6434b0364 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 30 Apr 2007 02:39:34 +0000 Subject: r22589: Make TALLOC_ARRAY consistent across all uses. Jeremy. (This used to be commit 8968808c3b5b0208cbad9ac92eaf948f2c546dd9) --- source3/nsswitch/winbindd_cache.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'source3/nsswitch/winbindd_cache.c') diff --git a/source3/nsswitch/winbindd_cache.c b/source3/nsswitch/winbindd_cache.c index da8983dda2..47bd872f03 100644 --- a/source3/nsswitch/winbindd_cache.c +++ b/source3/nsswitch/winbindd_cache.c @@ -1794,11 +1794,15 @@ static NTSTATUS lookup_useraliases(struct winbindd_domain *domain, *num_aliases = centry_uint32(centry); *alias_rids = NULL; - (*alias_rids) = TALLOC_ARRAY(mem_ctx, uint32, *num_aliases); + if (*num_aliases) { + (*alias_rids) = TALLOC_ARRAY(mem_ctx, uint32, *num_aliases); - if ((*num_aliases != 0) && ((*alias_rids) == NULL)) { - centry_free(centry); - return NT_STATUS_NO_MEMORY; + if ((*alias_rids) == NULL) { + centry_free(centry); + return NT_STATUS_NO_MEMORY; + } + } else { + (*alias_rids) = NULL; } for (i=0; i<(*num_aliases); i++) @@ -1962,15 +1966,21 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain, *num_domains = centry_uint32(centry); - (*names) = TALLOC_ARRAY(mem_ctx, char *, *num_domains); - (*alt_names) = TALLOC_ARRAY(mem_ctx, char *, *num_domains); - (*dom_sids) = TALLOC_ARRAY(mem_ctx, DOM_SID, *num_domains); + if (*num_domains) { + (*names) = TALLOC_ARRAY(mem_ctx, char *, *num_domains); + (*alt_names) = TALLOC_ARRAY(mem_ctx, char *, *num_domains); + (*dom_sids) = TALLOC_ARRAY(mem_ctx, DOM_SID, *num_domains); - if (! (*dom_sids) || ! (*names) || ! (*alt_names)) { - smb_panic_fn("trusted_domains out of memory"); - centry_free(centry); - return NT_STATUS_NO_MEMORY; - } + if (! (*dom_sids) || ! (*names) || ! (*alt_names)) { + smb_panic_fn("trusted_domains out of memory"); + centry_free(centry); + return NT_STATUS_NO_MEMORY; + } + } else { + (*names) = NULL; + (*alt_names) = NULL; + (*dom_sids) = NULL; + } for (i=0; i<(*num_domains); i++) { (*names)[i] = centry_string(centry, mem_ctx); -- cgit