From: Jeremy Allison Date: Wed, 9 Sep 2020 17:14:30 +0000 (-0700) Subject: s3: libsmb: Tidy up the talloc heirarchy allocation in get_dc_list(). X-Git-Tag: talloc-2.3.2~491 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e0d060c632c2a61cfe5c61b2ad9ee5b09be02855;p=thirdparty%2Fsamba.git s3: libsmb: Tidy up the talloc heirarchy allocation in get_dc_list(). 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 Reviewed-by: Noel Power --- diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index ad3f073b5cd..5b8bdd3a8fd 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -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;