summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2012-08-23 12:33:43 -0400
committerDan Winship <danw@gnome.org>2012-08-27 07:23:59 -0400
commit48a9887eae1058b055994c832b26a8ab9876db57 (patch)
tree559cf76292668924ff8baa0e98f85971b8240710
parentb901aaf6731d836b036aa1cee63087aa3fdc0768 (diff)
downloadglib-48a9887eae1058b055994c832b26a8ab9876db57.tar.gz
gmain: free source_lists when freeing GMainContext
If a context was freed with sources still attached, those sources correctly got destroyed, but the corresponding GSourceList structs were being leaked. https://bugzilla.gnome.org/show_bug.cgi?id=682560
-rw-r--r--glib/gmain.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/glib/gmain.c b/glib/gmain.c
index 603dd3fdf..4274269a2 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -499,6 +499,8 @@ g_main_context_unref (GMainContext *context)
{
GSourceIter iter;
GSource *source;
+ GList *sl_iter;
+ GSourceList *list;
g_return_if_fail (context != NULL);
g_return_if_fail (g_atomic_int_get (&context->ref_count) > 0);
@@ -516,6 +518,12 @@ g_main_context_unref (GMainContext *context)
source->context = NULL;
g_source_destroy_internal (source, context, FALSE);
}
+ for (sl_iter = context->source_lists; sl_iter; sl_iter = sl_iter->next)
+ {
+ list = sl_iter->data;
+ g_slice_free (GSourceList, list);
+ }
+ g_list_free (context->source_lists);
g_mutex_clear (&context->mutex);