From: Guus Sliepen Date: Mon, 19 Oct 2015 18:46:27 +0000 (+0200) Subject: Fix a memory leak. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=09ee8ab4685761cf33ac4cbf37e171917565e000;p=utcp Fix a memory leak. The receive buffer was never freed. --- diff --git a/utcp.c b/utcp.c index 5ba4eaa..c93d4bb 100644 --- a/utcp.c +++ b/utcp.c @@ -273,6 +273,7 @@ static void free_connection(struct utcp_connection *c) { memmove(cp, cp + 1, (utcp->nconnections - i - 1) * sizeof *cp); utcp->nconnections--; + buffer_exit(&c->rcvbuf); buffer_exit(&c->sndbuf); free(c); } @@ -318,6 +319,7 @@ static struct utcp_connection *allocate_connection(struct utcp *utcp, uint16_t s } if(!buffer_init(&c->rcvbuf, DEFAULT_RCVBUFSIZE, DEFAULT_MAXRCVBUFSIZE)) { + buffer_exit(&c->sndbuf); free(c); return NULL; } @@ -1416,6 +1418,7 @@ void utcp_exit(struct utcp *utcp) { for(int i = 0; i < utcp->nconnections; i++) { if(!utcp->connections[i]->reapable) debug("Warning, freeing unclosed connection %p\n", utcp->connections[i]); + buffer_exit(&utcp->connections[i]->rcvbuf); buffer_exit(&utcp->connections[i]->sndbuf); free(utcp->connections[i]); }