From e29eaa43f511750cc1670b7154ef936496b46a39 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 6 Apr 2018 11:04:24 +0200 Subject: [PATCH] idmap: Fix CID 1363261 Resource leak Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/winbindd/idmap_ad_nss.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source3/winbindd/idmap_ad_nss.c b/source3/winbindd/idmap_ad_nss.c index 8e960b8a21e..0fd2b51e156 100644 --- a/source3/winbindd/idmap_ad_nss.c +++ b/source3/winbindd/idmap_ad_nss.c @@ -290,7 +290,7 @@ static NTSTATUS nss_ad_map_from_alias( TALLOC_CTX *mem_ctx, LDAPMessage *msg = NULL; ADS_STATUS ads_status = ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL); NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; - char *username; + char *username = NULL; struct idmap_domain *dom; struct idmap_ad_context *ctx = NULL; @@ -339,7 +339,8 @@ static NTSTATUS nss_ad_map_from_alias( TALLOC_CTX *mem_ctx, username = ads_pull_string(ctx->ads, mem_ctx, msg, "sAMAccountName"); if (!username) { - return NT_STATUS_OBJECT_NAME_NOT_FOUND; + nt_status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + goto done; } *name = talloc_asprintf(mem_ctx, "%s\\%s", @@ -353,6 +354,7 @@ static NTSTATUS nss_ad_map_from_alias( TALLOC_CTX *mem_ctx, nt_status = NT_STATUS_OK; done: + TALLOC_FREE(username); TALLOC_FREE(filter); if (msg) { ads_msgfree(ctx->ads, msg);