r764: More memleak fixes in error code path from kawasa_r@itg.hitachi.co.jp.
authorJeremy Allison <jra@samba.org>
Tue, 18 May 2004 01:05:59 +0000 (01:05 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:51:37 +0000 (10:51 -0500)
Jeremy.
(This used to be commit 9647394e7c79c81ac4cf276a2c4b9e16eb053ec2)

source3/libads/ldap.c

index e156857e96fee6ac86fdb4859e7d30eedd5f6d91..e018eeb2da9c93e6822baf05816d73478695436a 100644 (file)
@@ -1980,17 +1980,22 @@ ADS_STATUS ads_server_info(ADS_STRUCT *ads)
        }
 
        status = ads_do_search(ads, "", LDAP_SCOPE_BASE, "(objectclass=*)", attrs, &res);
-       if (!ADS_ERR_OK(status)) return status;
+       if (!ADS_ERR_OK(status)) {
+               talloc_destroy(ctx);
+               return status;
+       }
 
        value = ads_pull_string(ads, ctx, res, "ldapServiceName");
        if (!value) {
                ads_msgfree(ads, res);
+               talloc_destroy(ctx);
                return ADS_ERROR(LDAP_NO_RESULTS_RETURNED);
        }
 
        timestr = ads_pull_string(ads, ctx, res, "currentTime");
        if (!timestr) {
                ads_msgfree(ads, res);
+               talloc_destroy(ctx);
                return ADS_ERROR(LDAP_NO_RESULTS_RETURNED);
        }