[evolution-mapi/gnome-3-4] Bug #677266 - Memory leaks when synchronizing for offline
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi/gnome-3-4] Bug #677266 - Memory leaks when synchronizing for offline
- Date: Wed, 6 Jun 2012 09:13:23 +0000 (UTC)
commit 1f8dcc50d129c5ba2585396d0b2adb02aa5c5cb6
Author: Milan Crha <mcrha redhat com>
Date: Wed Jun 6 11:13:01 2012 +0200
Bug #677266 - Memory leaks when synchronizing for offline
src/camel/camel-mapi-folder-summary.c | 3 +-
src/camel/camel-mapi-store.c | 1 +
src/libexchangemapi/e-mapi-book-utils.c | 6 +++-
src/libexchangemapi/e-mapi-cal-utils.c | 2 +
src/libexchangemapi/e-mapi-connection.c | 38 +++++++++++++++++++++++++--
src/libexchangemapi/e-mapi-fast-transfer.c | 3 ++
src/libexchangemapi/e-mapi-mail-utils.c | 14 +++++++---
7 files changed, 58 insertions(+), 9 deletions(-)
---
diff --git a/src/camel/camel-mapi-folder-summary.c b/src/camel/camel-mapi-folder-summary.c
index db5b8c1..230ec97 100644
--- a/src/camel/camel-mapi-folder-summary.c
+++ b/src/camel/camel-mapi-folder-summary.c
@@ -128,9 +128,10 @@ camel_mapi_folder_summary_new (CamelFolder *folder)
We need to pass the ex and find out why it is not loaded etc. ? */
camel_folder_summary_clear (summary, NULL);
g_warning ("Unable to load summary %s\n", local_error ? local_error->message : "Unknown error");
- g_clear_error (&local_error);
}
+ g_clear_error (&local_error);
+
return summary;
}
diff --git a/src/camel/camel-mapi-store.c b/src/camel/camel-mapi-store.c
index 677cda1..ac781a3 100644
--- a/src/camel/camel-mapi-store.c
+++ b/src/camel/camel-mapi-store.c
@@ -2594,6 +2594,7 @@ mapi_authenticate_sync (CamelService *service,
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_UNAVAILABLE,
mapi_error->message);
+ g_clear_error (&mapi_error);
result = CAMEL_AUTHENTICATION_ERROR;
} else {
/* mapi_error should be set */
diff --git a/src/libexchangemapi/e-mapi-book-utils.c b/src/libexchangemapi/e-mapi-book-utils.c
index eddd5c6..a013bcb 100644
--- a/src/libexchangemapi/e-mapi-book-utils.c
+++ b/src/libexchangemapi/e-mapi-book-utils.c
@@ -127,6 +127,7 @@ e_mapi_book_utils_contact_from_object (EMapiConnection *conn,
const gchar *book_uri)
{
EContact *contact;
+ gchar *email_1;
const mapi_id_t *pmid;
gint i;
@@ -341,13 +342,16 @@ e_mapi_book_utils_contact_from_object (EMapiConnection *conn,
}
}
- if (!e_contact_get (contact, E_CONTACT_EMAIL_1)) {
+ email_1 = e_contact_get (contact, E_CONTACT_EMAIL_1);
+ if (!email_1) {
gconstpointer value = get_proptag (PidTagPrimarySmtpAddress);
if (value)
e_contact_set (contact, E_CONTACT_EMAIL_1, value);
}
+ g_free (email_1);
+
#undef get_proptag
#undef get_str_proptag
diff --git a/src/libexchangemapi/e-mapi-cal-utils.c b/src/libexchangemapi/e-mapi-cal-utils.c
index 66e86c1..2abf26f 100644
--- a/src/libexchangemapi/e-mapi-cal-utils.c
+++ b/src/libexchangemapi/e-mapi-cal-utils.c
@@ -1210,6 +1210,7 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
e_cal_component_alarm_set_trigger (e_alarm, trigger);
e_cal_component_add_alarm (comp, e_alarm);
+ e_cal_component_alarm_free (e_alarm);
}
} else
e_cal_component_remove_all_alarms (comp);
@@ -1260,6 +1261,7 @@ e_mapi_cal_util_object_to_comp (EMapiConnection *conn,
e_cal_component_alarm_set_trigger (e_alarm, trigger);
e_cal_component_add_alarm (comp, e_alarm);
+ e_cal_component_alarm_free (e_alarm);
}
} else
e_cal_component_remove_all_alarms (comp);
diff --git a/src/libexchangemapi/e-mapi-connection.c b/src/libexchangemapi/e-mapi-connection.c
index 3f2adcc..ef27648 100644
--- a/src/libexchangemapi/e-mapi-connection.c
+++ b/src/libexchangemapi/e-mapi-connection.c
@@ -1355,6 +1355,9 @@ e_mapi_connection_get_folder_properties (EMapiConnection *conn,
make_mapi_error (perror, "GetPropsAll", ms);
goto cleanup;
}
+
+ if (properties)
+ properties->lpProps = talloc_steal (properties, properties->lpProps);
}
if (g_cancellable_set_error_if_cancelled (cancellable, perror))
@@ -2442,6 +2445,9 @@ fetch_object_attachment_cb (EMapiConnection *conn,
goto cleanup;
}
+ if (attachment->properties.lpProps)
+ attachment->properties.lpProps = talloc_steal (attachment, attachment->properties.lpProps);
+
attach_method = e_mapi_util_find_row_propval (srow, PidTagAttachMethod);
if (attach_method && *attach_method == ATTACH_BY_VALUE) {
if (!e_mapi_util_find_array_propval (&attachment->properties, PidTagAttachDataBinary)) {
@@ -2522,6 +2528,9 @@ e_mapi_connection_fetch_object_internal (EMapiConnection *conn,
goto cleanup;
}
+ if (object->properties.lpProps)
+ object->properties.lpProps = talloc_steal (object, object->properties.lpProps);
+
/* to transform named ids to their PidLid or PidName tags, like the fast-transfer does */
ms = QueryNamedProperties (obj_message, 0, NULL, &np_count, &np_propID, &np_nameid);
if (ms != MAPI_E_SUCCESS) {
@@ -2806,7 +2815,7 @@ e_mapi_connection_transfer_objects (EMapiConnection *conn,
while (iter) {
mapi_id_array_t ids;
- ms = mapi_id_array_init (priv->mapi_ctx, &ids);
+ ms = mapi_id_array_init (mem_ctx, &ids);
if (ms != MAPI_E_SUCCESS) {
make_mapi_error (perror, "mapi_id_array_init", ms);
goto cleanup;
@@ -3591,6 +3600,9 @@ add_object_recipients (EMapiConnection *conn,
}
cleanup:
+ talloc_free (rows);
+ talloc_free (flagList);
+
UNLOCK ();
g_free (users);
@@ -5419,12 +5431,14 @@ e_mapi_connection_copymove_items (EMapiConnection *conn,
GError **perror)
{
enum MAPISTATUS ms = MAPI_E_RESERVED;
+ TALLOC_CTX *mem_ctx;
GSList *l;
CHECK_CORRECT_CONN_AND_GET_PRIV (conn, MAPI_E_INVALID_PARAMETER);
e_return_val_mapi_error_if_fail (priv->session != NULL, MAPI_E_INVALID_PARAMETER, MAPI_E_INVALID_PARAMETER);
LOCK ();
+ mem_ctx = talloc_new (priv->session);
if (g_cancellable_set_error_if_cancelled (cancellable, perror)) {
ms = MAPI_E_USER_CANCEL;
@@ -5435,7 +5449,7 @@ e_mapi_connection_copymove_items (EMapiConnection *conn,
mapi_id_array_t msg_id_array;
gint count = 0;
- mapi_id_array_init (conn->priv->mapi_ctx, &msg_id_array);
+ mapi_id_array_init (mem_ctx, &msg_id_array);
for (l = mid_list; l != NULL && count < 500; l = g_slist_next (l), count++)
mapi_id_array_add_id (&msg_id_array, *((mapi_id_t *)l->data));
@@ -5457,6 +5471,7 @@ e_mapi_connection_copymove_items (EMapiConnection *conn,
}
cleanup:
+ talloc_free (mem_ctx);
UNLOCK ();
return ms == MAPI_E_SUCCESS;
@@ -6059,8 +6074,15 @@ e_mapi_connection_ex_to_smtp (EMapiConnection *conn,
PR_SMTP_ADDRESS_UNICODE);
ms = ResolveNames (priv->session, (const gchar **)str_array, SPropTagArray, &SRowSet, &flaglist, MAPI_UNICODE);
- if (ms != MAPI_E_SUCCESS)
+ if (ms != MAPI_E_SUCCESS) {
+ talloc_free (SRowSet);
+ talloc_free (flaglist);
+
+ SRowSet = NULL;
+ flaglist = NULL;
+
ms = ResolveNames (priv->session, (const gchar **)str_array, SPropTagArray, &SRowSet, &flaglist, 0);
+ }
if (g_cancellable_set_error_if_cancelled (cancellable, perror)) {
ms = MAPI_E_USER_CANCEL;
@@ -6072,6 +6094,8 @@ e_mapi_connection_ex_to_smtp (EMapiConnection *conn,
*display_name = g_strdup (e_mapi_util_find_row_propval (SRowSet->aRow, PR_DISPLAY_NAME_UNICODE));
}
+ talloc_free (SRowSet);
+ talloc_free (flaglist);
talloc_free (mem_ctx);
UNLOCK ();
@@ -6170,6 +6194,12 @@ e_mapi_connection_resolve_username (EMapiConnection *conn,
if (g_cancellable_set_error_if_cancelled (cancellable, perror)) {
ms = MAPI_E_USER_CANCEL;
} else {
+ talloc_free (rows);
+ talloc_free (flaglist);
+
+ rows = NULL;
+ flaglist = NULL;
+
ms = ResolveNames (priv->session, str_array, tag_array, &rows, &flaglist, 0);
}
}
@@ -6238,6 +6268,8 @@ e_mapi_connection_resolve_username (EMapiConnection *conn,
cleanup:
g_free (named_ids_list);
+ talloc_free (rows);
+ talloc_free (flaglist);
talloc_free (mem_ctx);
UNLOCK ();
diff --git a/src/libexchangemapi/e-mapi-fast-transfer.c b/src/libexchangemapi/e-mapi-fast-transfer.c
index b09db52..d680692 100644
--- a/src/libexchangemapi/e-mapi-fast-transfer.c
+++ b/src/libexchangemapi/e-mapi-fast-transfer.c
@@ -409,11 +409,14 @@ e_mapi_fast_transfer_internal (EMapiConnection *conn,
do {
DATA_BLOB transferdata;
+ transferdata.data = NULL;
+
ms = FXGetBuffer (fasttransfer_ctx, 0, &transferStatus, &stepCount, &totalCount, &transferdata);
if (ms != MAPI_E_SUCCESS)
break;
ms = fxparser_parse (parser, &transferdata);
+ talloc_free (transferdata.data);
if (ms != MAPI_E_SUCCESS)
break;
diff --git a/src/libexchangemapi/e-mapi-mail-utils.c b/src/libexchangemapi/e-mapi-mail-utils.c
index 3b0ee93..a60e920 100644
--- a/src/libexchangemapi/e-mapi-mail-utils.c
+++ b/src/libexchangemapi/e-mapi-mail-utils.c
@@ -672,14 +672,19 @@ build_multipart_alternative (EMapiObject *object, GSList *inline_attachments)
static CamelMultipart *
build_multipart_mixed (CamelMultipart *content, GSList *attachments)
{
- CamelMimePart *part = camel_mime_part_new ();
CamelMultipart *m_mixed = camel_multipart_new ();
camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (m_mixed), "multipart/mixed");
camel_multipart_set_boundary (m_mixed, NULL);
- camel_medium_set_content (CAMEL_MEDIUM (part), CAMEL_DATA_WRAPPER (content));
- camel_multipart_add_part (m_mixed, part);
- g_object_unref (part);
+ if (content) {
+ CamelMimePart *part = camel_mime_part_new ();
+
+ camel_medium_set_content (CAMEL_MEDIUM (part), CAMEL_DATA_WRAPPER (content));
+ camel_multipart_add_part (m_mixed, part);
+
+ g_object_unref (part);
+ g_object_unref (content);
+ }
add_multipart_attachments (m_mixed, attachments);
@@ -791,6 +796,7 @@ e_mapi_mail_utils_object_to_message (EMapiConnection *conn, /* const */ EMapiObj
addr = camel_internet_address_new ();
camel_internet_address_add (addr, name, email);
camel_mime_message_set_from (msg, addr);
+ g_object_unref (addr);
}
g_free (name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]