From a87558047bb3e187a6533680b9251bc9f3416883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Mon, 11 May 2015 23:09:40 +0200 Subject: [PATCH] Fix iomux_select_recalc_max, it went to an infinite loop. --- src/iomux_select.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/iomux_select.c b/src/iomux_select.c index fb1517a..bdf0029 100644 --- a/src/iomux_select.c +++ b/src/iomux_select.c @@ -27,15 +27,14 @@ static int iomux_select_update_events(struct IOMux *mux_, struct IOMuxFD *fd); static void iomux_select_recalc_max(struct IOMuxSelect *mux) { size_t i; + size_t n; mux->max_fd = -1; - for (i = 0; i < mux->num_descriptors; ) { + for (i = 0, n = 0; i < FD_SETSIZE && n < mux->num_descriptors; i++) { if (mux->descriptors[i] != NULL) { mux->max_fd = UC_MAX(mux->descriptors[i]->fd, mux->max_fd); - i++; + n++; } - - assert(i < FD_SETSIZE); } }