don't call ads_destroy() twice; fixes segfault in winbindd when DC goes down; bug 437
[kai/samba.git] / source / libads / ldap_utils.c
index 1fa9ebfc975e9fce943cb37aa3c4d33dcd924975..4142bceabca2f0c5c8e4200c3b430e0ed39affb9 100644 (file)
@@ -54,15 +54,20 @@ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope
                        return status;
                }
 
-               if (*res) ads_msgfree(ads, *res);
+               if (*res) 
+                       ads_msgfree(ads, *res);
                *res = NULL;
+               
                DEBUG(3,("Reopening ads connection to realm '%s' after error %s\n", 
                         ads->config.realm, ads_errstr(status)));
+                        
                if (ads->ld) {
                        ldap_unbind(ads->ld); 
                }
+               
                ads->ld = NULL;
                status = ads_connect(ads);
+               
                if (!ADS_ERR_OK(status)) {
                        DEBUG(1,("ads_search_retry: failed to reconnect (%s)\n",
                                 ads_errstr(status)));