summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index bc8c9ae..b96ba65 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1356,7 +1356,8 @@ static PyMethodDef PySocketSock_methods[] = {
static void
BUILD_FUNC_DEF_1(PySocketSock_dealloc,PySocketSockObject *,s)
{
- (void) close(s->sock_fd);
+ if (s->sock_fd != -1)
+ (void) close(s->sock_fd);
PyMem_DEL(s);
}