const char **attrs, void *args,
LDAPMessage **res)
{
- ADS_STATUS status = ADS_SUCCESS;
+ ADS_STATUS status;
int count = 3;
char *bp;
status = ads_connect(ads);
if (!ADS_ERR_OK(status)) {
+ bool orig_is_mine = ads->is_mine;
+
DEBUG(1,("ads_search_retry: failed to reconnect (%s)\n",
ads_errstr(status)));
+ /*
+ * We need to keep the ads pointer
+ * from being freed here as we don't own it and
+ * callers depend on it being around.
+ */
+ ads->is_mine = false;
ads_destroy(&ads);
+ ads->is_mine = orig_is_mine;
SAFE_FREE(bp);
return status;
}