diff --git a/os/connection.c b/os/connection.c index d975f87..4b04f2f 100644 --- a/os/connection.c +++ b/os/connection.c @@ -1068,9 +1068,11 @@ AddEnabledDevice(int fd) _X_EXPORT void RemoveGeneralSocket(int fd) { - FD_CLR(fd, &AllSockets); - if (GrabInProgress) - FD_CLR(fd, &SavedAllSockets); + if (fd != -1) { + FD_CLR(fd, &AllSockets); + if (GrabInProgress) + FD_CLR(fd, &SavedAllSockets); + } } _X_EXPORT void