summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-03-03 15:06:09 +0100
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-03-03 15:06:09 +0100
commitef2a4f128fa0250db5457069e397bf328c6da25e (patch)
treebca214380c41311fe1d7e9d05f77f42c4e1b3161
parent52a5113760802e16b07d9d954237871d52cff70a (diff)
downloadouroboros-ef2a4f128fa0250db5457069e397bf328c6da25e.tar.gz
ouroboros-ef2a4f128fa0250db5457069e397bf328c6da25e.zip
lib, irmd: Fix memleaks
Fixes a couple of memleaks found while executing with valgrind.
-rw-r--r--src/irmd/main.c11
-rw-r--r--src/lib/irm.c8
2 files changed, 8 insertions, 11 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 73533ef0..0c69de2f 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -78,18 +78,12 @@ static void unreg_ipcp(rina_name_t * name,
int main()
{
int sockfd;
- uint8_t * buf;
+ uint8_t buf[IRM_MSG_BUF_SIZE];
sockfd = server_socket_open(IRM_SOCK_PATH);
if (sockfd < 0)
return -1;
- buf = malloc(sizeof(*buf) * IRM_MSG_BUF_SIZE);
- if (buf == NULL) {
- LOG_ERR("Cannot allocate memory");
- return -ENOMEM;
- }
-
while (true) {
int cli_sockfd;
struct irm_msg * msg;
@@ -140,12 +134,11 @@ int main()
LOG_ERR("Don't know that message code");
break;
}
+ free(msg);
}
close(cli_sockfd);
}
- free(buf);
-
return 0;
}
diff --git a/src/lib/irm.c b/src/lib/irm.c
index 97000029..8756d7fc 100644
--- a/src/lib/irm.c
+++ b/src/lib/irm.c
@@ -26,6 +26,7 @@
#include <ouroboros/common.h>
#include <ouroboros/logs.h>
#include <ouroboros/sockets.h>
+#include <stdlib.h>
static int send_irm_msg(struct irm_msg * msg)
{
@@ -47,8 +48,11 @@ static int send_irm_msg(struct irm_msg * msg)
return -1;
}
- close(sockfd);
- return 0;
+ free(buf->data);
+ free(buf);
+
+ close(sockfd);
+ return 0;
}
int irm_create_ipcp(rina_name_t name,