[evolution] Calendar: Fix several memory leaks
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Calendar: Fix several memory leaks
- Date: Thu, 18 Feb 2021 13:02:58 +0000 (UTC)
commit 2ebf44077273c9b4194a02197195371139eee6e8
Author: Milan Crha <mcrha redhat com>
Date: Thu Feb 18 13:51:01 2021 +0100
Calendar: Fix several memory leaks
src/calendar/gui/e-comp-editor-page-general.c | 2 ++
src/calendar/gui/e-comp-editor-page-recurrence.c | 1 +
src/calendar/gui/e-comp-editor-property-part.c | 1 +
src/calendar/gui/e-comp-editor.c | 2 ++
src/calendar/gui/e-meeting-store.c | 40 +++++++++++++++---------
src/calendar/gui/itip-utils.c | 3 ++
src/modules/itip-formatter/itip-view.c | 3 +-
7 files changed, 37 insertions(+), 15 deletions(-)
---
diff --git a/src/calendar/gui/e-comp-editor-page-general.c b/src/calendar/gui/e-comp-editor-page-general.c
index 6d6d543801..0d17d2eed2 100644
--- a/src/calendar/gui/e-comp-editor-page-general.c
+++ b/src/calendar/gui/e-comp-editor-page-general.c
@@ -959,6 +959,8 @@ ecep_general_fill_widgets (ECompEditorPage *page,
g_clear_object (&comp_editor);
g_free (value);
}
+
+ g_object_unref (prop);
}
attendees_list_view = E_MEETING_LIST_VIEW (page_general->priv->attendees_list_view);
diff --git a/src/calendar/gui/e-comp-editor-page-recurrence.c
b/src/calendar/gui/e-comp-editor-page-recurrence.c
index e3f308d473..c13aecf414 100644
--- a/src/calendar/gui/e-comp-editor-page-recurrence.c
+++ b/src/calendar/gui/e-comp-editor-page-recurrence.c
@@ -200,6 +200,7 @@ ecep_recurrence_update_preview (ECompEditorPageRecurrence *page_recurrence)
dt = i_cal_component_get_dtstart (icomp);
zone = i_cal_time_get_timezone (dt);
+ g_object_unref (dt);
}
if (!zone)
diff --git a/src/calendar/gui/e-comp-editor-property-part.c b/src/calendar/gui/e-comp-editor-property-part.c
index f1227552db..393f0f4aa3 100644
--- a/src/calendar/gui/e-comp-editor-property-part.c
+++ b/src/calendar/gui/e-comp-editor-property-part.c
@@ -866,6 +866,7 @@ ecepp_datetime_fill_widget (ECompEditorPropertyPart *property_part,
}
g_clear_object (&timezone_entry);
+ g_clear_object (&prop);
}
if (!value)
diff --git a/src/calendar/gui/e-comp-editor.c b/src/calendar/gui/e-comp-editor.c
index 2e3372fa0c..56ba488abd 100644
--- a/src/calendar/gui/e-comp-editor.c
+++ b/src/calendar/gui/e-comp-editor.c
@@ -1397,6 +1397,8 @@ e_comp_editor_prompt_and_save_changes (ECompEditor *comp_editor,
ece_save_component (comp_editor, component, with_send, TRUE);
+ g_clear_object (&component);
+
return FALSE;
case GTK_RESPONSE_NO: /* Discard */
return TRUE;
diff --git a/src/calendar/gui/e-meeting-store.c b/src/calendar/gui/e-meeting-store.c
index 01e6b35fd3..1311abb3f5 100644
--- a/src/calendar/gui/e-meeting-store.c
+++ b/src/calendar/gui/e-meeting-store.c
@@ -617,6 +617,7 @@ refresh_queue_remove (EMeetingStore *store,
g_mutex_unlock (&priv->mutex);
g_ptr_array_free (qdata->call_backs, TRUE);
g_ptr_array_free (qdata->data, TRUE);
+ g_string_free (qdata->string, TRUE);
g_free (qdata);
}
@@ -1636,11 +1637,21 @@ typedef struct {
EMeetingStore *store;
} FreeBusyAsyncData;
+static void
+free_busy_data_free (FreeBusyAsyncData *fbd)
+{
+ if (fbd) {
+ g_slist_free_full (fbd->users, g_free);
+ g_free (fbd->email);
+ g_slice_free (FreeBusyAsyncData, fbd);
+ }
+}
+
#define USER_SUB "%u"
#define DOMAIN_SUB "%d"
-static gboolean
-freebusy_async (gpointer data)
+static gpointer
+freebusy_async_thread (gpointer data)
{
FreeBusyAsyncData *fbd = data;
EMeetingAttendee *attendee = fbd->attendee;
@@ -1661,9 +1672,6 @@ freebusy_async (gpointer data)
priv->num_queries--;
g_mutex_unlock (&mutex);
- g_slist_foreach (fbd->users, (GFunc) g_free, NULL);
- g_slist_free (fbd->users);
-
if (fbd->fb_data != NULL) {
ECalComponent *comp = fbd->fb_data->data;
gchar *comp_str;
@@ -1672,14 +1680,16 @@ freebusy_async (gpointer data)
process_free_busy (fbd->qdata, comp_str);
g_free (comp_str);
- return TRUE;
+ free_busy_data_free (fbd);
+ return NULL;
}
}
/* Look for fburl's of attendee with no free busy info on server */
if (!e_meeting_attendee_is_set_address (attendee)) {
process_callbacks (fbd->qdata);
- return TRUE;
+ free_busy_data_free (fbd);
+ return NULL;
}
/* Check for free busy info on the default server */
@@ -1714,7 +1724,9 @@ freebusy_async (gpointer data)
process_callbacks (fbd->qdata);
}
- return TRUE;
+ free_busy_data_free (fbd);
+
+ return NULL;
}
#undef USER_SUB
@@ -1761,7 +1773,7 @@ refresh_busy_periods (gpointer data)
/* We take a ref in case we get destroyed in the gui during a callback */
g_object_ref (qdata->store);
- fbd = g_new0 (FreeBusyAsyncData, 1);
+ fbd = g_slice_new0 (FreeBusyAsyncData);
fbd->client = priv->client;
fbd->attendee = attendee;
fbd->users = NULL;
@@ -1809,18 +1821,18 @@ refresh_busy_periods (gpointer data)
store->priv->num_threads++;
g_mutex_unlock (&store->priv->mutex);
- thread = g_thread_try_new (NULL, (GThreadFunc) freebusy_async, fbd, &error);
+ thread = g_thread_try_new (NULL, freebusy_async_thread, fbd, &error);
if (!thread) {
- /* do clean up stuff here */
- g_slist_foreach (fbd->users, (GFunc) g_free, NULL);
- g_slist_free (fbd->users);
- g_free (fbd->email);
+ free_busy_data_free (fbd);
+
priv->refresh_idle_id = 0;
g_mutex_lock (&store->priv->mutex);
store->priv->num_threads--;
g_mutex_unlock (&store->priv->mutex);
+ g_object_unref (store);
+
return FALSE;
}
diff --git a/src/calendar/gui/itip-utils.c b/src/calendar/gui/itip-utils.c
index f4f7742a51..1fae476214 100644
--- a/src/calendar/gui/itip-utils.c
+++ b/src/calendar/gui/itip-utils.c
@@ -191,6 +191,8 @@ itip_get_user_identities (ESourceRegistry *registry)
g_ptr_array_add (identities, camel_internet_address_format_address
(alias_name, alias_address));
}
}
+
+ g_object_unref (inet_address);
}
g_free (aliases);
@@ -398,6 +400,7 @@ itip_has_any_attendees (ECalComponent *comp)
itip_strip_mailto (e_cal_component_organizer_get_value (organizer))) != 0);
g_slist_free_full (attendees, e_cal_component_attendee_free);
+ e_cal_component_organizer_free (organizer);
return res;
}
diff --git a/src/modules/itip-formatter/itip-view.c b/src/modules/itip-formatter/itip-view.c
index 9bfaa1c94b..359d358727 100644
--- a/src/modules/itip-formatter/itip-view.c
+++ b/src/modules/itip-formatter/itip-view.c
@@ -5200,7 +5200,7 @@ update_attendee_status_icomp (ItipView *view,
ICalComponent *icomp)
{
ECalComponent *comp;
- GSList *attendees;
+ GSList *attendees = NULL;
gboolean is_instance;
is_instance = e_cal_component_is_instance (view->priv->comp);
@@ -5345,6 +5345,7 @@ update_attendee_status_icomp (ItipView *view,
view);
cleanup:
+ g_slist_free_full (attendees, e_cal_component_attendee_free);
g_object_unref (comp);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]