From 72dc46584cec3652c910b7c414e83353a5b536e9 Mon Sep 17 00:00:00 2001 From: Philipp Stephani Date: Wed, 30 Dec 2020 22:17:52 +0100 Subject: [PATCH] * src/nsterm.m (ns_select): Fix off-by-one error, and add assertion --- src/nsterm.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nsterm.m b/src/nsterm.m index 161677484f9..1a23fc6912c 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -4697,7 +4697,8 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds, return -1; } - for (k = 0; k < nfds+1; k++) + eassert (nfds <= FD_SETSIZE); + for (k = 0; k < nfds; k++) { if (readfds && FD_ISSET(k, readfds)) ++nr; if (writefds && FD_ISSET(k, writefds)) ++nr; -- 2.39.5