diff options
author | Jeremy Allison <jra@samba.org> | 2007-04-30 02:51:26 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:19:49 -0500 |
commit | 56a5d05b8b285250bdc0e9cc3c8f3c3d8af80382 (patch) | |
tree | fe800dc017985b616874b79ffad6122a1e5bde34 /source3 | |
parent | be8b0685a55700c6bce3681734800ec6434b0364 (diff) | |
download | samba-56a5d05b8b285250bdc0e9cc3c8f3c3d8af80382.tar.gz samba-56a5d05b8b285250bdc0e9cc3c8f3c3d8af80382.tar.bz2 samba-56a5d05b8b285250bdc0e9cc3c8f3c3d8af80382.zip |
r22590: Make TALLOC_ARRAY consistent across all uses.
That should be it....
Jeremy.
(This used to be commit 603233a98bbf65467c8b4f04719d771c70b3b4c9)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/secace.c | 8 | ||||
-rw-r--r-- | source3/libads/dns.c | 12 | ||||
-rw-r--r-- | source3/libgpo/gpo_ldap.c | 28 | ||||
-rw-r--r-- | source3/libmsrpc/libmsrpc_internal.c | 10 | ||||
-rw-r--r-- | source3/nsswitch/idmap.c | 12 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_ads.c | 25 | ||||
-rw-r--r-- | source3/registry/regfio.c | 8 | ||||
-rw-r--r-- | source3/smbd/msdfs.c | 12 | ||||
-rw-r--r-- | source3/utils/net_rpc_samsync.c | 12 |
9 files changed, 87 insertions, 40 deletions
diff --git a/source3/lib/secace.c b/source3/lib/secace.c index d60722c57e..871c983533 100644 --- a/source3/lib/secace.c +++ b/source3/lib/secace.c @@ -122,8 +122,12 @@ NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, SEC_ACE **pp_new, SEC_ACE *old, uint32 if (!ctx || !pp_new || !old || !sid || !num) return NT_STATUS_INVALID_PARAMETER; - if((pp_new[0] = TALLOC_ZERO_ARRAY(ctx, SEC_ACE, *num )) == 0) - return NT_STATUS_NO_MEMORY; + if (*num) { + if((pp_new[0] = TALLOC_ZERO_ARRAY(ctx, SEC_ACE, *num )) == 0) + return NT_STATUS_NO_MEMORY; + } else { + pp_new[0] = NULL; + } for (i = 0; i < *num; i ++) { if (sid_compare(&old[i].trustee, sid) != 0) diff --git a/source3/libads/dns.c b/source3/libads/dns.c index 8b031b0e3a..f16cea2555 100644 --- a/source3/libads/dns.c +++ b/source3/libads/dns.c @@ -355,10 +355,14 @@ static NTSTATUS ads_dns_lookup_srv( TALLOC_CTX *ctx, const char *name, struct dn DEBUG(4,("ads_dns_lookup_srv: %d records returned in the answer section.\n", answer_count)); - if ( (dcs = TALLOC_ZERO_ARRAY(ctx, struct dns_rr_srv, answer_count)) == NULL ) { - DEBUG(0,("ads_dns_lookup_srv: talloc() failure for %d char*'s\n", - answer_count)); - return NT_STATUS_NO_MEMORY; + if (answer_count) { + if ( (dcs = TALLOC_ZERO_ARRAY(ctx, struct dns_rr_srv, answer_count)) == NULL ) { + DEBUG(0,("ads_dns_lookup_srv: talloc() failure for %d char*'s\n", + answer_count)); + return NT_STATUS_NO_MEMORY; + } + } else { + dcs = NULL; } /* now skip the header */ diff --git a/source3/libgpo/gpo_ldap.c b/source3/libgpo/gpo_ldap.c index 13ec80f2ad..6c1079832d 100644 --- a/source3/libgpo/gpo_ldap.c +++ b/source3/libgpo/gpo_ldap.c @@ -47,12 +47,17 @@ ADS_STATUS ads_parse_gp_ext(TALLOC_CTX *mem_ctx, gp_ext->num_exts = i; - gp_ext->extensions = TALLOC_ZERO_ARRAY(mem_ctx, char *, gp_ext->num_exts); - gp_ext->extensions_guid = TALLOC_ZERO_ARRAY(mem_ctx, char *, gp_ext->num_exts); - gp_ext->snapins = TALLOC_ZERO_ARRAY(mem_ctx, char *, gp_ext->num_exts); - gp_ext->snapins_guid = TALLOC_ZERO_ARRAY(mem_ctx, char *, gp_ext->num_exts); - - gp_ext->gp_extension = talloc_strdup(mem_ctx, extension_raw); + if (gp_ext->num_exts) { + gp_ext->extensions = TALLOC_ZERO_ARRAY(mem_ctx, char *, gp_ext->num_exts); + gp_ext->extensions_guid = TALLOC_ZERO_ARRAY(mem_ctx, char *, gp_ext->num_exts); + gp_ext->snapins = TALLOC_ZERO_ARRAY(mem_ctx, char *, gp_ext->num_exts); + gp_ext->snapins_guid = TALLOC_ZERO_ARRAY(mem_ctx, char *, gp_ext->num_exts); + } else { + gp_ext->extensions = NULL; + gp_ext->extensions_guid = NULL; + gp_ext->snapins = NULL; + gp_ext->snapins_guid = NULL; + } if (gp_ext->extensions == NULL || gp_ext->extensions_guid == NULL || gp_ext->snapins == NULL || gp_ext->snapins_guid == NULL || @@ -60,6 +65,8 @@ ADS_STATUS ads_parse_gp_ext(TALLOC_CTX *mem_ctx, goto parse_error; } + gp_ext->gp_extension = talloc_strdup(mem_ctx, extension_raw); + for (i = 0; ext_list[i] != NULL; i++) { int k; @@ -161,8 +168,13 @@ ADS_STATUS ads_parse_gplink(TALLOC_CTX *mem_ctx, gp_link->gp_opts = options; gp_link->num_links = i; - gp_link->link_names = TALLOC_ZERO_ARRAY(mem_ctx, char *, gp_link->num_links); - gp_link->link_opts = TALLOC_ZERO_ARRAY(mem_ctx, uint32, gp_link->num_links); + if (gp_link->num_links) { + gp_link->link_names = TALLOC_ZERO_ARRAY(mem_ctx, char *, gp_link->num_links); + gp_link->link_opts = TALLOC_ZERO_ARRAY(mem_ctx, uint32, gp_link->num_links); + } else { + gp_link->link_names = NULL; + gp_link->link_opts = NULL; + } gp_link->gp_link = talloc_strdup(mem_ctx, gp_link_raw); diff --git a/source3/libmsrpc/libmsrpc_internal.c b/source3/libmsrpc/libmsrpc_internal.c index 3cb702e376..a06915b72c 100644 --- a/source3/libmsrpc/libmsrpc_internal.c +++ b/source3/libmsrpc/libmsrpc_internal.c @@ -713,9 +713,13 @@ CacService *cac_MakeServiceArray( TALLOC_CTX * mem_ctx, if ( !mem_ctx || !svc ) return NULL; - services = TALLOC_ZERO_ARRAY( mem_ctx, CacService, num_services ); - if ( !services ) - return NULL; + if (num_services) { + services = TALLOC_ZERO_ARRAY( mem_ctx, CacService, num_services ); + if ( !services ) + return NULL; + } else { + services = NULL; + } for ( i = 0; i < num_services; i++ ) { services[i].service_name = diff --git a/source3/nsswitch/idmap.c b/source3/nsswitch/idmap.c index 26fcc692e9..5222eba8f3 100644 --- a/source3/nsswitch/idmap.c +++ b/source3/nsswitch/idmap.c @@ -1026,9 +1026,15 @@ static NTSTATUS idmap_backends_sids_to_unixids(struct id_map **ids) /* split list per domain */ - dom_ids = TALLOC_ZERO_ARRAY(ctx, struct id_map **, num_domains); - IDMAP_CHECK_ALLOC(dom_ids); - counters = TALLOC_ZERO_ARRAY(ctx, int, num_domains); + if (num_domains) { + dom_ids = TALLOC_ZERO_ARRAY(ctx, struct id_map **, num_domains); + IDMAP_CHECK_ALLOC(dom_ids); + counters = TALLOC_ZERO_ARRAY(ctx, int, num_domains); + IDMAP_CHECK_ALLOC(counters); + } else { + dom_ids = NULL; + counters = NULL; + } /* partition the requests by domain */ diff --git a/source3/nsswitch/winbindd_ads.c b/source3/nsswitch/winbindd_ads.c index 01174edf37..355a093855 100644 --- a/source3/nsswitch/winbindd_ads.c +++ b/source3/nsswitch/winbindd_ads.c @@ -907,16 +907,21 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain, the problem is that the members are in the form of distinguised names */ - (*sid_mem) = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID, num_members); - (*name_types) = TALLOC_ZERO_ARRAY(mem_ctx, uint32, num_members); - (*names) = TALLOC_ZERO_ARRAY(mem_ctx, char *, num_members); - - if ((num_members != 0) && - ((members == NULL) || (*sid_mem == NULL) || - (*name_types == NULL) || (*names == NULL))) { - DEBUG(1, ("talloc failed\n")); - status = NT_STATUS_NO_MEMORY; - goto done; + if (num_members) { + (*sid_mem) = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID, num_members); + (*name_types) = TALLOC_ZERO_ARRAY(mem_ctx, uint32, num_members); + (*names) = TALLOC_ZERO_ARRAY(mem_ctx, char *, num_members); + + if ((members == NULL) || (*sid_mem == NULL) || + (*name_types == NULL) || (*names == NULL)) { + DEBUG(1, ("talloc failed\n")); + status = NT_STATUS_NO_MEMORY; + goto done; + } + } else { + (*sid_mem) = NULL; + (*name_types) = NULL; + (*names) = NULL; } for (i=0;i<num_members;i++) { diff --git a/source3/registry/regfio.c b/source3/registry/regfio.c index f7ea58f8a3..3a554177a4 100644 --- a/source3/registry/regfio.c +++ b/source3/registry/regfio.c @@ -1823,8 +1823,12 @@ static int hashrec_cmp( REGF_HASH_REC *h1, REGF_HASH_REC *h2 ) memcpy( nk->subkeys.header, "lf", REC_HDR_SIZE ); nk->subkeys.num_keys = nk->num_subkeys; - if ( !(nk->subkeys.hashes = TALLOC_ZERO_ARRAY( file->mem_ctx, REGF_HASH_REC, nk->subkeys.num_keys )) ) - return NULL; + if (nk->subkeys.num_keys) { + if ( !(nk->subkeys.hashes = TALLOC_ZERO_ARRAY( file->mem_ctx, REGF_HASH_REC, nk->subkeys.num_keys )) ) + return NULL; + } else { + nk->subkeys.hashes = NULL; + } nk->subkey_index = 0; /* update the max_bytes_subkey{name,classname} fields */ diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c index effe868657..9f203bfd19 100644 --- a/source3/smbd/msdfs.c +++ b/source3/smbd/msdfs.c @@ -264,10 +264,14 @@ static BOOL parse_msdfs_symlink(TALLOC_CTX *ctx, DEBUG(10,("parse_msdfs_symlink: count=%d\n", count)); - reflist = *preflist = TALLOC_ZERO_ARRAY(ctx, struct referral, count); - if(reflist == NULL) { - DEBUG(0,("parse_msdfs_symlink: talloc failed!\n")); - return False; + if (count) { + reflist = *preflist = TALLOC_ZERO_ARRAY(ctx, struct referral, count); + if(reflist == NULL) { + DEBUG(0,("parse_msdfs_symlink: talloc failed!\n")); + return False; + } + } else { + reflist = *preflist = NULL; } for(i=0;i<count;i++) { diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index 3e19a12ac5..d8ddff20bc 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -670,10 +670,14 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta) return NT_STATUS_NO_MEMORY; } - if ((nt_members = TALLOC_ZERO_ARRAY(t, char *, delta->num_members)) == NULL) { - DEBUG(0, ("talloc failed\n")); - talloc_free(t); - return NT_STATUS_NO_MEMORY; + if (delta->num_members) { + if ((nt_members = TALLOC_ZERO_ARRAY(t, char *, delta->num_members)) == NULL) { + DEBUG(0, ("talloc failed\n")); + talloc_free(t); + return NT_STATUS_NO_MEMORY; + } + } else { + nt_members = NULL; } for (i=0; i<delta->num_members; i++) { |