mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-14 04:57:46 +02:00
gmain: fix double-unlock in g_main_context_unref()
When unreffing a context with sources still attached, it would end up unlocking an already-unlocked context, causing crashes on platforms that (unlike Linux) actually check for that. https://bugzilla.gnome.org/show_bug.cgi?id=697595
This commit is contained in:
@@ -520,12 +520,16 @@ g_main_context_unref (GMainContext *context)
|
|||||||
main_context_list = g_slist_remove (main_context_list, context);
|
main_context_list = g_slist_remove (main_context_list, context);
|
||||||
G_UNLOCK (main_context_list);
|
G_UNLOCK (main_context_list);
|
||||||
|
|
||||||
|
/* g_source_iter_next() assumes the context is locked. */
|
||||||
|
LOCK_CONTEXT (context);
|
||||||
g_source_iter_init (&iter, context, TRUE);
|
g_source_iter_init (&iter, context, TRUE);
|
||||||
while (g_source_iter_next (&iter, &source))
|
while (g_source_iter_next (&iter, &source))
|
||||||
{
|
{
|
||||||
source->context = NULL;
|
source->context = NULL;
|
||||||
g_source_destroy_internal (source, context, FALSE);
|
g_source_destroy_internal (source, context, TRUE);
|
||||||
}
|
}
|
||||||
|
UNLOCK_CONTEXT (context);
|
||||||
|
|
||||||
for (sl_iter = context->source_lists; sl_iter; sl_iter = sl_iter->next)
|
for (sl_iter = context->source_lists; sl_iter; sl_iter = sl_iter->next)
|
||||||
{
|
{
|
||||||
list = sl_iter->data;
|
list = sl_iter->data;
|
||||||
|
Reference in New Issue
Block a user