aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog17
-rw-r--r--addressbook/backend/pas/pas-backend-ldap.c35
2 files changed, 40 insertions, 12 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 3d348e60f0..838eac0841 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,20 @@
+2002-03-27 Chris Toshok <toshok@ximian.com>
+
+ * backend/pas/pas-backend-ldap.c (check_schema_support): make sure
+ to call ldap_value_free (values);, and ldap_msgfree (resp).
+ (get_ldap_library_info): don't ask me why, but it appears we have
+ to free each extension char*.
+ (query_ldap_root_dse): make sure to free values in the
+ subschemaSubentry code before overwriting it, and call
+ ldap_msgfree(resp) when we're all done.
+ (build_card_from_entry): don't leak the DN, ldap attributes, or
+ the berval the ldap_*_attribute calls use to step through the
+ attributes. the docs say this berval is freed when
+ ldap_next_attribute returns NULL, but if we don't free it it leaks
+ a substantial amount of memory.
+ (pas_backend_ldap_search): make sure to only allocate *op once,
+ and fix the g_warning since op isn't valid in its scope anymore.
+
2002-03-19 Dan Winship <danw@ximian.com>
* backend/ebook/Makefile.am: Update for libversit change: Use .a
diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c
index f9f092117d..378b3ad553 100644
--- a/addressbook/backend/pas/pas-backend-ldap.c
+++ b/addressbook/backend/pas/pas-backend-ldap.c
@@ -415,7 +415,11 @@ check_schema_support (PASBackendLDAP *bl)
ldap_objectclass_free (oc);
}
+
+ ldap_value_free (values);
}
+
+ ldap_msgfree (resp);
}
}
@@ -447,6 +451,8 @@ get_ldap_library_info ()
for (i = 0; info.ldapai_extensions[i]; i++) {
char *extension = info.ldapai_extensions[i];
g_message (extension);
+ /* yuck. we have to free this? */
+ ldap_memfree (extension);
}
}
@@ -520,9 +526,11 @@ query_ldap_root_dse (PASBackendLDAP *bl)
}
values = ldap_get_values (ldap, resp, "subschemaSubentry");
- if (!values || !values[0])
+ if (!values || !values[0]) {
+ if (values) ldap_value_free (values);
values = ldap_get_values (ldap, resp, "schemaNamingContext");
- if (values || values[0]) {
+ }
+ if (values && values[0]) {
bl->priv->schema_dn = g_strdup (values[0]);
}
else {
@@ -531,6 +539,7 @@ query_ldap_root_dse (PASBackendLDAP *bl)
if (values)
ldap_value_free (values);
+ ldap_msgfree (resp);
}
static GNOME_Evolution_Addressbook_BookListener_CallStatus
@@ -2497,12 +2506,13 @@ build_card_from_entry (LDAP *ldap, LDAPMessage *e, GList **existing_objectclasse
{
ECard *ecard = E_CARD(gtk_type_new(e_card_get_type()));
ECardSimple *card = e_card_simple_new (ecard);
- char *dn = ldap_get_dn(ldap, e);
+ char *dn;
char *attr;
BerElement *ber = NULL;
- // g_print ("build_card_from_entry, dn = %s\n", dn);
+ dn = ldap_get_dn(ldap, e);
e_card_simple_set_id (card, dn);
+ ldap_memfree (dn);
for (attr = ldap_first_attribute (ldap, e, &ber); attr;
attr = ldap_next_attribute (ldap, e, ber)) {
@@ -2542,15 +2552,17 @@ build_card_from_entry (LDAP *ldap, LDAPMessage *e, GList **existing_objectclasse
}
}
}
+
+ ldap_memfree (attr);
}
-#ifndef OPENLDAP2
- /* if ldap->ld_errno == LDAP_DECODING_ERROR there was an
- error decoding an attribute, and we shouldn't free ber,
- since the ldap library already did it. */
- if (ldap->ld_errno != LDAP_DECODING_ERROR && ber)
+ /* XXX the openldap man page for
+ ldap_first_attribute/ldap_next_attribute says that the ber
+ is freed if there are no more attributes
+ (ldap_next_attribute returns NULL), but this seems to not
+ be the case (as of openldap-2.0.23), so free it here. */
+ if (ber)
ber_free (ber, 0);
-#endif
e_card_simple_sync_card (card);
@@ -2721,7 +2733,6 @@ pas_backend_ldap_search (PASBackendLDAP *bl,
PASBook *book,
PASBackendLDAPBookView *view)
{
- LDAPSearchOp *search_op = g_new0 (LDAPSearchOp, 1);
char *ldap_query;
pas_book_view_notify_status_message (view->book_view, _("Searching..."));
@@ -2774,7 +2785,7 @@ pas_backend_ldap_search (PASBackendLDAP *bl,
return;
}
else {
- g_warning ("LDAP problem converting search query %s\n", search_op->view->search);
+ g_warning ("LDAP problem converting search query %s\n", view->search);
pas_book_view_notify_status_message (view->book_view, _("Could not parse query string"));
return;
}