From 9b73e821efb6d87a7b6f24f58a92a81414e57e99 Mon Sep 17 00:00:00 2001 From: gambas Date: Fri, 12 Oct 2018 17:12:06 +0200 Subject: [PATCH] Fix a file descriptor leak when a socket fails to connect. [GB.NET] * BUG: Fix a file descriptor leak when a socket fails to connect. --- gb.net/src/CSocket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gb.net/src/CSocket.c b/gb.net/src/CSocket.c index a19fba32a..0a140a8e8 100644 --- a/gb.net/src/CSocket.c +++ b/gb.net/src/CSocket.c @@ -164,9 +164,9 @@ static void CSocket_close(CSOCKET *_object) THIS->DnsTool = NULL; } - if (SOCKET->status > NET_INACTIVE) /* if it's not connected, does nothing */ + fd = SOCKET->socket; + if (fd >= 0) { - fd = SOCKET->socket; //fprintf(stderr, "CSocket_close: %p: set fd %d to -1\n", THIS, fd); SOCKET->socket = -1;