aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-02-05 18:20:22 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-02-05 18:20:22 +0000
commit1e08514471896e3b3069cdc25f457036d257cc68 (patch)
treeb591aa5d3eac5fec70d137d664ccc4b95db63cc4 /src/libutil/util.c
parent9068c5040e2737ce70f0cc9498000efa30c14c74 (diff)
downloadrspamd-1e08514471896e3b3069cdc25f457036d257cc68.tar.gz
rspamd-1e08514471896e3b3069cdc25f457036d257cc68.zip
Fix potential issues as found by coverity.
Diffstat (limited to 'src/libutil/util.c')
-rw-r--r--src/libutil/util.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 9b9d17fb0..465dd92c6 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -129,7 +129,7 @@ static gint
rspamd_inet_socket_create (gint type, struct addrinfo *addr, gboolean is_server,
gboolean async, GList **list)
{
- gint fd, r, optlen, on = 1, s_error;
+ gint fd = -1, r, optlen, on = 1, s_error;
struct addrinfo *cur;
cur = addr;
@@ -425,7 +425,7 @@ rspamd_sockets_list (const gchar *credits, guint16 port,
struct sockaddr_un un;
struct stat st;
struct addrinfo hints, *res;
- gint r, fd, serrno;
+ gint r, fd = -1, serrno;
gchar portbuf[8], **strv, **cur;
GList *result = NULL, *rcur;
@@ -486,9 +486,14 @@ rspamd_sockets_list (const gchar *credits, guint16 port,
rspamd_snprintf (portbuf, sizeof (portbuf), "%d", (int)port);
if ((r = getaddrinfo (credits, portbuf, &hints, &res)) == 0) {
- r = rspamd_inet_socket_create (type, res, is_server, async, &result);
+ fd = rspamd_inet_socket_create (type, res, is_server, async, &result);
freeaddrinfo (res);
+
if (result == NULL) {
+ if (fd != -1) {
+ close (fd);
+ }
+
goto err;
}
}
@@ -499,6 +504,7 @@ rspamd_sockets_list (const gchar *credits, guint16 port,
goto err;
}
}
+
cur++;
}