s3: libsmb: Cleanup in get_dc_list()
authorNoel Power <noel.power@suse.com>
Fri, 4 Sep 2020 11:23:14 +0000 (12:23 +0100)
committerNoel Power <npower@samba.org>
Mon, 7 Sep 2020 14:46:58 +0000 (14:46 +0000)
Don't modify out params (unless successful result),

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Mon Sep  7 14:46:58 UTC 2020 on sn-devel-184

source3/libsmb/namequery.c

index d4c04962e7310fb53d89070112cf09e4a4b03c87..0bcbb815a64eaffeaaa866812d5df1298883e1d6 100644 (file)
@@ -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);