From 5ef5c81e7972e70dbc8ed57a0489b6396434ae53 Mon Sep 17 00:00:00 2001
From: dscho <dscho>
Date: Tue, 18 Feb 2003 15:49:14 +0000
Subject: fixed a bug when closing a client if no longer listening for new
 clients.

---
 sockets.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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);
-- 
cgit v1.2.3

