Bug 523463 – Core dump in gmain.c:2482:IA__g_main_context_check()

2008-09-09  Matthias Clasen  <mclasen@redhat.com>

        Bug 523463 – Core dump in gmain.c:2482:IA__g_main_context_check()

        * glib/gmain.c (g_main_context_check): Be robust against setting
        event fields on the fly, as e.g. happens in linc. Tracked down
        by Paul Smith, fix proposed by Owen Taylor.

svn path=/trunk/; revision=7447
This commit is contained in:
Matthias Clasen 2008-09-09 06:04:21 +00:00 committed by Matthias Clasen
parent a8539d10d4
commit b36ea0b1c7
2 changed files with 28 additions and 19 deletions

View File

@ -1,3 +1,11 @@
2008-09-09 Matthias Clasen <mclasen@redhat.com>
Bug 523463 Core dump in gmain.c:2482:IA__g_main_context_check()
* glib/gmain.c (g_main_context_check): Be robust against setting
event fields on the fly, as e.g. happens in linc. Tracked down
by Paul Smith, fix proposed by Owen Taylor.
2008-09-08 Christian Dywan <christian@imendio.com>
Bug 550433 g_test_init doesn't recognize --help

View File

@ -2525,8 +2525,11 @@ g_main_context_query (GMainContext *context,
n_poll = 0;
while (pollrec && max_priority >= pollrec->priority)
{
if (pollrec->fd->events)
{
/* We need to include entries with fd->events == 0 in the array because
* otherwise if the application changes fd->events behind our back and
* makes it non-zero, we'll be out of sync when we check the fds[] array.
* (Changing fd->events after adding an FD wasn't an anticipated use of
* this API, but it occurs in practice.) */
if (n_poll < n_fds)
{
fds[n_poll].fd = pollrec->fd->fd;
@ -2538,10 +2541,9 @@ g_main_context_query (GMainContext *context,
fds[n_poll].events = pollrec->fd->events & ~(G_IO_ERR|G_IO_HUP|G_IO_NVAL);
fds[n_poll].revents = 0;
}
n_poll++;
}
pollrec = pollrec->next;
n_poll++;
}
#ifdef G_THREADS_ENABLED
@ -2619,11 +2621,10 @@ g_main_context_check (GMainContext *context,
while (i < n_fds)
{
if (pollrec->fd->events)
{
pollrec->fd->revents = fds[i].revents;
i++;
}
pollrec = pollrec->next;
i++;
}
source = next_valid_source (context, NULL);