diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-12-05 06:26:56 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-12-05 06:26:56 +0000 |
commit | 5f76385e709204151fb9c743ae9d36e0b3df48de (patch) | |
tree | 894f06129f78795d2aa9bb1ddf5c0915e9943b55 | |
parent | faa0f63774e6b121eb61ffb009f60087894b5399 (diff) | |
download | samba-5f76385e709204151fb9c743ae9d36e0b3df48de.tar.gz samba-5f76385e709204151fb9c743ae9d36e0b3df48de.tar.bz2 samba-5f76385e709204151fb9c743ae9d36e0b3df48de.zip |
more memory leak fixes
(This used to be commit eb6f0e91ddd2a97a907a569bc60beca99b494884)
-rw-r--r-- | source3/libads/ads_struct.c | 8 | ||||
-rw-r--r-- | source3/libads/ldap.c | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/source3/libads/ads_struct.c b/source3/libads/ads_struct.c index 4227684375..2d8bf06156 100644 --- a/source3/libads/ads_struct.c +++ b/source3/libads/ads_struct.c @@ -139,7 +139,7 @@ ADS_STRUCT *ads_init(const char *realm, ADS_STRUCT *ads; ads = (ADS_STRUCT *)smb_xmalloc(sizeof(*ads)); - memset(ads, 0, sizeof(*ads)); + ZERO_STRUCTP(ads); ads->realm = realm? strdup(realm) : NULL; ads->ldap_server = ldap_server? strdup(ldap_server) : NULL; @@ -147,7 +147,7 @@ ADS_STRUCT *ads_init(const char *realm, ads->ldap_port = LDAP_PORT; if (!ads->realm) { - ads->realm = lp_realm(); + ads->realm = strdup(lp_realm()); if (!ads->realm[0]) { ads->realm = get_default_realm(ads); } @@ -157,7 +157,7 @@ ADS_STRUCT *ads_init(const char *realm, ads->bind_path = ads_build_dn(ads->realm); } if (!ads->ldap_server) { - ads->ldap_server = lp_ads_server(); + ads->ldap_server = strdup(lp_ads_server()); if (!ads->ldap_server[0]) { ads->ldap_server = find_ldap_server(ads); } @@ -175,7 +175,7 @@ ADS_STRUCT *ads_init(const char *realm, */ void ads_destroy(ADS_STRUCT **ads) { - if (False && (ads) && (*ads)) { + if (ads && *ads) { if ((*ads)->ld) ldap_unbind((*ads)->ld); SAFE_FREE((*ads)->realm); SAFE_FREE((*ads)->ldap_server); diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index 34ca2ad04d..251a4a6958 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -100,6 +100,14 @@ int ads_search_dn(ADS_STRUCT *ads, void **res, LDAP_SCOPE_BASE, "(objectclass=*)", (char **)attrs, 0, (LDAPMessage **)res); } +/* + free up memory from a ads_search +*/ +void ads_msgfree(ADS_STRUCT *ads, void *msg) +{ + if (!msg) return; + ldap_msgfree(msg); +} /* find a machine account given a hostname |