From 84ca6e5f336670b6d5dc13927261c8549803bced Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 26 Dec 2013 21:51:15 +0000 Subject: [PATCH] Fix some cases in unix socket creation. --- src/util.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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); } -- 2.39.5