summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sockets.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sockets.c b/sockets.c
index 3f4d69b..3095ec0 100644
--- a/sockets.c
+++ b/sockets.c
@@ -330,7 +330,8 @@ rfbCloseClient(cl)
{
FD_CLR(cl->sock,&(cl->screen->allFds));
if(cl->sock==cl->screen->maxFd)
- while(!FD_ISSET(cl->screen->maxFd,&(cl->screen->allFds)))
+ while(cl->screen->maxFd>0
+ && !FD_ISSET(cl->screen->maxFd,&(cl->screen->allFds)))
cl->screen->maxFd--;
shutdown(cl->sock,SHUT_RDWR);
close(cl->sock);