From: Vsevolod Stakhov Date: Thu, 26 Dec 2013 21:51:15 +0000 (+0000) Subject: Fix some cases in unix socket creation. X-Git-Tag: 0.6.6~6 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=84ca6e5f336670b6d5dc13927261c8549803bced;p=rspamd.git Fix some cases in unix socket creation. --- diff --git a/src/util.c b/src/util.c index 50dbf7a37..b537e8827 100644 --- a/src/util.c +++ b/src/util.c @@ -220,8 +220,8 @@ accept_from_socket (gint listen_sock, struct sockaddr *addr, socklen_t * len) gint make_unix_socket (const gchar *path, struct sockaddr_un *addr, gint type, gboolean is_server, gboolean async) { - gint fd, s_error, r, optlen, serrno, on = 1; - struct stat st; + gint fd = -1, s_error, r, optlen, serrno, on = 1; + struct stat st; if (path == NULL) return -1; @@ -307,7 +307,9 @@ make_unix_socket (const gchar *path, struct sockaddr_un *addr, gint type, gboole out: serrno = errno; - close (fd); + if (fd != -1) { + close (fd); + } errno = serrno; return (-1); }