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/libads/dns.c | 22 +++++++++++++++------- source3/libads/ldap.c | 12 ++++++++---- 2 files changed, 23 insertions(+), 11 deletions(-) (limited to 'source3/libads') diff --git a/source3/libads/dns.c b/source3/libads/dns.c index 008266ea0b..8b031b0e3a 100644 --- a/source3/libads/dns.c +++ b/source3/libads/dns.c @@ -283,9 +283,13 @@ static NTSTATUS dns_send_req( TALLOC_CTX *ctx, const char *name, int q_type, buf_len = resp_len * sizeof(uint8); - if ( (buffer = TALLOC_ARRAY(ctx, uint8, buf_len)) == NULL ) { - DEBUG(0,("ads_dns_lookup_srv: talloc() failed!\n")); - return NT_STATUS_NO_MEMORY; + if (buf_len) { + if ( (buffer = TALLOC_ARRAY(ctx, uint8, buf_len)) == NULL ) { + DEBUG(0,("ads_dns_lookup_srv: talloc() failed!\n")); + return NT_STATUS_NO_MEMORY; + } + } else { + buffer = NULL; } if ( (resp_len = res_query(name, C_IN, q_type, buffer, buf_len)) < 0 ) { @@ -499,10 +503,14 @@ NTSTATUS ads_dns_lookup_ns( TALLOC_CTX *ctx, const char *dnsdomain, struct dns_r DEBUG(4,("ads_dns_lookup_ns: %d records returned in the answer section.\n", answer_count)); - if ( (nsarray = TALLOC_ARRAY(ctx, struct dns_rr_ns, answer_count)) == NULL ) { - DEBUG(0,("ads_dns_lookup_ns: talloc() failure for %d char*'s\n", - answer_count)); - return NT_STATUS_NO_MEMORY; + if (answer_count) { + if ( (nsarray = TALLOC_ARRAY(ctx, struct dns_rr_ns, answer_count)) == NULL ) { + DEBUG(0,("ads_dns_lookup_ns: talloc() failure for %d char*'s\n", + answer_count)); + return NT_STATUS_NO_MEMORY; + } + } else { + nsarray = NULL; } /* now skip the header */ diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index 6707cbd4d0..5a34385c32 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -2225,10 +2225,14 @@ int ads_count_replies(ADS_STRUCT *ads, void *res) for (i=0; values[i]; i++) /* nop */ ; - (*sids) = TALLOC_ARRAY(mem_ctx, DOM_SID, i); - if (!(*sids)) { - ldap_value_free_len(values); - return 0; + if (i) { + (*sids) = TALLOC_ARRAY(mem_ctx, DOM_SID, i); + if (!(*sids)) { + ldap_value_free_len(values); + return 0; + } + } else { + (*sids) = NULL; } count = 0; -- cgit