From 59bdd08214831b268dd7c4981db8404da9c11e3a Mon Sep 17 00:00:00 2001 From: vienna Date: Tue, 7 Mar 2017 16:14:05 +0000 Subject: [PATCH] fix #3847: add close socket before return ANET_ERR. --- src/anet.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/anet.c b/src/anet.c index ef1711d06..993615601 100644 --- a/src/anet.c +++ b/src/anet.c @@ -380,8 +380,10 @@ int anetUnixGenericConnect(char *err, char *path, int flags) sa.sun_family = AF_LOCAL; strncpy(sa.sun_path,path,sizeof(sa.sun_path)-1); if (flags & ANET_CONNECT_NONBLOCK) { - if (anetNonBlock(err,s) != ANET_OK) + if (anetNonBlock(err,s) != ANET_OK) { + close(s); return ANET_ERR; + } } if (connect(s,(struct sockaddr*)&sa,sizeof(sa)) == -1) { if (errno == EINPROGRESS &&