commit d88c59d3690e7c14edfc99411479c245de62e3aa
Author:     Andreas Schneider <asn@samba.org>
AuthorDate: Wed Oct 5 10:32:16 2016 +0200
Commit:     Andreas Schneider <asn@samba.org>
CommitDate: Wed Oct 5 10:32:16 2016 +0200

    s3-winbind: Fix memory leak in ad_idmap_cached_connection_internal()
    
    Signed-off-by: Andreas Schneider <asn@samba.org>
---
 source3/winbindd/idmap_ad.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c
index 2b35a4f..2b21051 100644
--- a/source3/winbindd/idmap_ad.c
+++ b/source3/winbindd/idmap_ad.c
@@ -127,7 +127,9 @@ static ADS_STATUS ad_idmap_cached_connection_internal(struct idmap_domain *dom)
 		realm = wb_dom->alt_name;
 	}
 
-	if ( (ads = ads_init(realm, dom->name, ldap_server)) == NULL ) {
+	ads = ads_init(realm, dom->name, ldap_server);
+	SAFE_FREE(ldap_server);
+	if (ads == NULL) {
 		DEBUG(1,("ads_init failed\n"));
 		return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
 	}
