Fix crash when the number of file descriptors grows and then shrinks

This is a bit of an embarrassing bug. The allocated size of the array
and the number of elements are not always the same.

Reported by Fridtjof Busse.
This commit is contained in:
David Benjamin 2011-06-28 20:30:26 -07:00
parent 253d41890a
commit 173fc6a221
1 changed files with 2 additions and 2 deletions

View File

@ -4961,10 +4961,10 @@ static int do_main(int argc, char **argv, const char *connection_path)
}
/* POLL */
(g_main_context_get_poll_func(context))(fds, nfds, timeout);
(g_main_context_get_poll_func(context))(fds, needed_fds + 1, timeout);
/* CHECK */
bool ready = g_main_context_check(context, max_priority, fds + 1, nfds - 1);
bool ready = g_main_context_check(context, max_priority, fds + 1, needed_fds);
/* DISPATCH */
if (ready) {