From 68f03d5e7a3d284acb3d987bcb6c69fed047f239 Mon Sep 17 00:00:00 2001 From: Adam Hess Date: Thu, 4 Jan 2024 09:17:27 -0800 Subject: [PATCH] Plug small memory leak in socket resolution --- src/socket.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/socket.c b/src/socket.c index 64d8f334..954be5cd 100644 --- a/src/socket.c +++ b/src/socket.c @@ -100,8 +100,15 @@ static int _cb_raw_close(trilogy_sock_t *_sock) if (sock->fd != -1) { rc = close(sock->fd); } + if (sock->addr) { - freeaddrinfo(sock->addr); + if (sock->base.opts.hostname == NULL && sock->base.opts.path != NULL) { + /* We created these with calloc so must free them instead of calling freeaddrinfo */ + free(sock->addr->ai_addr); + free(sock->addr); + } else { + freeaddrinfo(sock->addr); + } } free(sock->base.opts.hostname);