From ef2a4f128fa0250db5457069e397bf328c6da25e Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Thu, 3 Mar 2016 15:06:09 +0100 Subject: lib, irmd: Fix memleaks Fixes a couple of memleaks found while executing with valgrind. --- src/irmd/main.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/irmd') 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; } -- cgit v1.2.3