summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2017-08-23 19:38:57 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2017-08-23 19:38:57 +0200
commit47bd452352389925188ca4d36ae1c1ba611e6aeb (patch)
tree8a307b5138b18dba0ed277d4deb85a8ca8e64347
parent1ca26ab86712575a5e89dcd68295b57fd27c5703 (diff)
downloadouroboros-47bd452352389925188ca4d36ae1c1ba611e6aeb.tar.gz
ouroboros-47bd452352389925188ca4d36ae1c1ba611e6aeb.zip
lib, ipcpd, irmd: Fix several memleaks
This fixes several memleaks as reported by valgrind. It also fixes some calls to close() with -1.
-rw-r--r--src/ipcpd/ipcp.c4
-rw-r--r--src/ipcpd/normal/dht.c2
-rw-r--r--src/ipcpd/normal/dt.c4
-rw-r--r--src/irmd/main.c6
-rw-r--r--src/lib/dev.c1
-rw-r--r--src/lib/sockets.c2
6 files changed, 10 insertions, 9 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index 300c22f4..ff45407b 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -184,10 +184,8 @@ static void * mainloop(void * o)
if (sfd == -1) {
pthread_mutex_unlock(&ipcpi.cmd_lock);
- if (tpm_check()) {
- close(sfd);
+ if (tpm_check())
break;
- }
continue;
}
diff --git a/src/ipcpd/normal/dht.c b/src/ipcpd/normal/dht.c
index 65e26406..b5d52d93 100644
--- a/src/ipcpd/normal/dht.c
+++ b/src/ipcpd/normal/dht.c
@@ -2340,7 +2340,7 @@ void dht_destroy(struct dht * dht)
list_for_each_safe(p, h, &dht->requests) {
struct kad_req * r = list_entry(p, struct kad_req, next);
list_del(&r->next);
- free(r);
+ kad_req_destroy(r);
}
list_for_each_safe(p, h, &dht->refs) {
diff --git a/src/ipcpd/normal/dt.c b/src/ipcpd/normal/dt.c
index 173266f4..f4ab2440 100644
--- a/src/ipcpd/normal/dt.c
+++ b/src/ipcpd/normal/dt.c
@@ -252,6 +252,10 @@ void dt_fini(void)
{
int i;
+ bmp_destroy(dt.res_fds);
+
+ pthread_rwlock_destroy(&dt.lock);
+
for (i = 0; i < QOS_CUBE_MAX; ++i)
routing_i_destroy(dt.routing[i]);
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 66c230c8..c8c75ef9 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -848,7 +848,7 @@ static int name_reg(const char * name,
continue;
hash = malloc(IPCP_HASH_LEN(e));
- if (hash == NULL)
+ if (hash == NULL)
break;
str_hash(e->dir_hash_algo, hash, name);
@@ -1827,10 +1827,8 @@ void * mainloop(void * o)
if (sfd == -1) {
pthread_mutex_unlock(&irmd.cmd_lock);
- if (tpm_check()) {
- close(sfd);
+ if (tpm_check())
break;
- }
continue;
}
diff --git a/src/lib/dev.c b/src/lib/dev.c
index 43543af3..8009a186 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -645,6 +645,7 @@ void ouroboros_fini()
free(ai.flows);
free(ai.ports);
+ free(ai.frcti);
pthread_rwlock_unlock(&ai.lock);
diff --git a/src/lib/sockets.c b/src/lib/sockets.c
index 9f1b326e..42676d11 100644
--- a/src/lib/sockets.c
+++ b/src/lib/sockets.c
@@ -98,7 +98,7 @@ irm_msg_t * send_recv_irm_msg(irm_msg_t * msg)
int sockfd;
uint8_t buf[IRM_MSG_BUF_SIZE];
ssize_t len;
- irm_msg_t * recv_msg;
+ irm_msg_t * recv_msg = NULL;
sockfd = client_socket_open(IRM_SOCK_PATH);
if (sockfd < 0)