From: Noel Power Date: Fri, 4 Sep 2020 11:23:14 +0000 (+0100) Subject: s3: libsmb: Cleanup in get_dc_list() X-Git-Tag: talloc-2.3.2~573 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7a3c368d787b9a7e203d29de184dff5a4d241052;p=thirdparty%2Fsamba.git s3: libsmb: Cleanup in get_dc_list() Don't modify out params (unless successful result), Signed-off-by: Noel Power Reviewed-by: Jeremy Allison Autobuild-User(master): Noel Power Autobuild-Date(master): Mon Sep 7 14:46:58 UTC 2020 on sn-devel-184 --- diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index d4c04962e73..0bcbb815a64 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -3831,7 +3831,8 @@ static NTSTATUS get_dc_list(TALLOC_CTX *ctx, int port; char *name; size_t num_addresses = 0; - size_t local_count, i; + size_t local_count = 0; + size_t i; struct ip_service *return_iplist = NULL; struct ip_service *auto_ip_list = NULL; bool done_auto_lookup = false; @@ -3840,9 +3841,6 @@ static NTSTATUS get_dc_list(TALLOC_CTX *ctx, TALLOC_CTX *frame = talloc_stackframe(); int auto_name_type = 0x1C; - *ip_list = NULL; - *ret_count = 0; - *ordered = False; /* if we are restricted to solely using DNS for looking @@ -4103,17 +4101,15 @@ static NTSTATUS get_dc_list(TALLOC_CTX *ctx, DEBUGADD(4,("\n")); } - *ip_list = return_iplist; - *ret_count = local_count; - - status = (*ret_count != 0 ? NT_STATUS_OK : NT_STATUS_NO_LOGON_SERVERS); + status = (local_count != 0 ? NT_STATUS_OK : NT_STATUS_NO_LOGON_SERVERS); out: - if (!NT_STATUS_IS_OK(status)) { + if (NT_STATUS_IS_OK(status)) { + *ip_list = return_iplist; + *ret_count = local_count; + } else { TALLOC_FREE(return_iplist); - *ip_list = NULL; - *ret_count = 0; } TALLOC_FREE(auto_ip_list);