]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: libsmb: Tidy up the talloc heirarchy allocation in get_dc_list().
authorJeremy Allison <jra@samba.org>
Wed, 9 Sep 2020 17:14:30 +0000 (10:14 -0700)
committerNoel Power <npower@samba.org>
Tue, 15 Sep 2020 10:09:40 +0000 (10:09 +0000)
Always allocate the return_salist off the frame pointer.
Only talloc_move() to return ctx on successful return.

Cleans up a nasty else in the exit path that caused
problems in the past - we can now always TALLOC_FREE(return_salist)
without remembering if we need to return it.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
source3/libsmb/namequery.c

index ad3f073b5cd6b698b387b0188ecdbcf21a507348..5b8bdd3a8fd9648aabb337e773aad20ad405addc 100644 (file)
@@ -4041,12 +4041,12 @@ static NTSTATUS get_dc_list(TALLOC_CTX *ctx,
                if (!NT_STATUS_IS_OK(status)) {
                        goto out;
                }
-               return_salist = talloc_move(ctx, &dc_salist);
+               return_salist = dc_salist;
                local_count = dc_count;
                goto out;
        }
 
-       return_salist = talloc_zero_array(ctx,
+       return_salist = talloc_zero_array(frame,
                                        struct samba_sockaddr,
                                        num_addresses);
        if (return_salist == NULL) {
@@ -4162,11 +4162,10 @@ static NTSTATUS get_dc_list(TALLOC_CTX *ctx,
   out:
 
        if (NT_STATUS_IS_OK(status)) {
-               *sa_list_ret = return_salist;
+               *sa_list_ret = talloc_move(ctx, &return_salist);
                *ret_count = local_count;
-       } else {
-               TALLOC_FREE(return_salist);
        }
+       TALLOC_FREE(return_salist);
        TALLOC_FREE(auto_sa_list);
        TALLOC_FREE(frame);
        return status;