Skip to content

Commit

Permalink
Plug small memory leak in socket resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
HParker authored and jhawthorn committed Jan 4, 2024
1 parent 46af52f commit 68f03d5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 68f03d5

Please sign in to comment.