summaryrefslogtreecommitdiff
path: root/src/common/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/socket.c')
-rw-r--r--src/common/socket.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/common/socket.c b/src/common/socket.c
index 262351dcf..8f60f8df5 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -1118,6 +1118,9 @@ void socket_final(void)
/// Closes a socket.
void do_close(int fd)
{
+ if( fd <= 0 ||fd >= FD_SETSIZE )
+ return;// invalid
+
flush_fifo(fd); // Try to send what's left (although it might not succeed since it's a nonblocking socket)
sFD_CLR(fd, &readfds);// this needs to be done before closing the socket
sShutdown(fd, SHUT_RDWR); // Disallow further reads/writes