* xgselect.c (xg_select): Don't assume n_gfds is nonnegative

merely because tmo_in_millisec is nonnegative.  The 1st call
to g_main_context_query could succeed while the 2nd one fails.
This commit is contained in:
Paul Eggert 2014-11-08 20:19:54 -08:00
parent 0cd3403ff4
commit f862694141
2 changed files with 6 additions and 2 deletions

View file

@ -1,5 +1,9 @@
2014-11-09 Paul Eggert <eggert@cs.ucla.edu>
* xgselect.c (xg_select): Don't assume n_gfds is nonnegative
merely because tmo_in_millisec is nonnegative. The 1st call
to g_main_context_query could succeed while the 2nd one fails.
* frame.c (Fcan_run_window_configuration_change_hook): Return a value.
2014-11-08 Jan Djärv <jan.h.d@swipnet.se>

View file

@ -56,7 +56,7 @@ xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds,
int gfds_size = ARRAYELTS (gfds_buf);
int n_gfds, retval = 0, our_fds = 0, max_fds = fds_lim - 1;
bool context_acquired = false;
int i, nfds, tmo_in_millisec = -1;
int i, nfds, tmo_in_millisec;
bool need_to_dispatch;
USE_SAFE_ALLOCA;
@ -102,7 +102,7 @@ xg_select (int fds_lim, fd_set *rfds, fd_set *wfds, fd_set *efds,
SAFE_FREE ();
if (tmo_in_millisec >= 0)
if (n_gfds >= 0 && tmo_in_millisec >= 0)
{
tmo = make_timespec (tmo_in_millisec / 1000,
1000 * 1000 * (tmo_in_millisec % 1000));