diff --git a/source3/libads/ads_struct.c b/source3/libads/ads_struct.c index d734d47e653..2a583efb685 100644 --- a/source3/libads/ads_struct.c +++ b/source3/libads/ads_struct.c @@ -153,7 +153,6 @@ static void ads_destroy(ADS_STRUCT **ads) #ifdef HAVE_LDAP ads_disconnect(*ads); #endif - SAFE_FREE((*ads)->config.server_site_name); SAFE_FREE((*ads)->config.client_site_name); SAFE_FREE((*ads)->config.schema_path); SAFE_FREE((*ads)->config.config_path); diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index 1693ab1debe..0a9a59447bb 100755 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -295,7 +295,7 @@ static bool ads_try_connect(ADS_STRUCT *ads, bool gc, TALLOC_FREE(ads->config.realm); TALLOC_FREE(ads->config.bind_path); TALLOC_FREE(ads->config.ldap_server_name); - SAFE_FREE(ads->config.server_site_name); + TALLOC_FREE(ads->config.server_site_name); SAFE_FREE(ads->config.client_site_name); TALLOC_FREE(ads->server.workgroup); @@ -332,8 +332,14 @@ static bool ads_try_connect(ADS_STRUCT *ads, bool gc, if (*cldap_reply.server_site) { ads->config.server_site_name = - SMB_STRDUP(cldap_reply.server_site); + talloc_strdup(ads, cldap_reply.server_site); + if (ads->config.server_site_name == NULL) { + DBG_WARNING("Out of memory\n"); + ret = false; + goto out; + } } + if (*cldap_reply.client_site) { ads->config.client_site_name = SMB_STRDUP(cldap_reply.client_site);