From 3707c5b8a67328be4cfa26317e263b6f0a3c716a Mon Sep 17 00:00:00 2001 From: Yves Rutschle Date: Sat, 13 May 2023 23:18:07 +0200 Subject: [PATCH] fix file descriptor leak if bind_peer fails --- common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/common.c b/common.c index a9916d9..59437f1 100644 --- a/common.c +++ b/common.c @@ -348,6 +348,7 @@ int connect_addr(struct connection *cnx, int fd_from, connect_blocking blocking) if (transparent) { res = bind_peer(fd, fd_from); + if (res == -1) close(fd); CHECK_RES_RETURN(res, "bind_peer", res); } res = connect(fd, a->ai_addr, a->ai_addrlen);