From f7633eca1824f7a5bda733e6753d5d1f850f78c3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 26 Sep 2006 16:27:18 +0000 Subject: r18923: Fix more memleaks. Guenther (This used to be commit ecb632a1534d5178602b9143bb17712559fe2e4f) --- source3/libads/ldap.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source3/libads/ldap.c') diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index 89c34f03a9..6077231ae2 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -2458,9 +2458,12 @@ ADS_STATUS ads_site_dn(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char **site_n service_name = ads_pull_string(ads, mem_ctx, res, "dsServiceName"); if (service_name == NULL) { + ads_msgfree(ads, res); return ADS_ERROR(LDAP_NO_RESULTS_RETURNED); } + ads_msgfree(ads, res); + /* go up three levels */ dn = ads_parent_dn(ads_parent_dn(ads_parent_dn(service_name))); if (dn == NULL) { @@ -2472,8 +2475,6 @@ ADS_STATUS ads_site_dn(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char **site_n return ADS_ERROR(LDAP_NO_MEMORY); } - ads_msgfree(ads, res); - return status; /* dsServiceName: CN=NTDS Settings,CN=W2K3DC,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=ber,DC=suse,DC=de @@ -2508,37 +2509,45 @@ ADS_STATUS ads_site_dn_for_machine(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const c config_context = ads_pull_string(ads, mem_ctx, res, "configurationNamingContext"); if (config_context == NULL) { + ads_msgfree(ads, res); return ADS_ERROR(LDAP_NO_MEMORY); } filter = talloc_asprintf(mem_ctx, "(cn=%s)", computer_name); if (filter == NULL) { + ads_msgfree(ads, res); return ADS_ERROR(LDAP_NO_MEMORY); } + ads_msgfree(ads, res); + status = ads_do_search(ads, config_context, LDAP_SCOPE_SUBTREE, filter, NULL, &res); if (!ADS_ERR_OK(status)) { return status; } if (ads_count_replies(ads, res) != 1) { + ads_msgfree(ads, res); return ADS_ERROR(LDAP_NO_SUCH_OBJECT); } dn = ads_get_dn(ads, res); if (dn == NULL) { + ads_msgfree(ads, res); return ADS_ERROR(LDAP_NO_MEMORY); } /* go up three levels */ parent = ads_parent_dn(ads_parent_dn(ads_parent_dn(dn))); if (parent == NULL) { + ads_msgfree(ads, res); ads_memfree(ads, dn); return ADS_ERROR(LDAP_NO_MEMORY); } *site_dn = talloc_strdup(mem_ctx, parent); if (*site_dn == NULL) { + ads_msgfree(ads, res); ads_memfree(ads, dn); ADS_ERROR(LDAP_NO_MEMORY); } -- cgit