From c36bd2304a5c2352c50cabcb05c6571b02a4b288 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Tue, 16 Dec 2025 17:22:27 +0100 Subject: [PATCH] connect: Close possibly leaking socket Signed-off-by: Jakub Jelen Reviewed-by: Andreas Schneider --- src/connect.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/connect.c b/src/connect.c index e0339514..b699ee54 100644 --- a/src/connect.c +++ b/src/connect.c @@ -335,6 +335,9 @@ socket_t ssh_connect_host_nonblocking(ssh_session session, const char *host, * connection, otherwise return the first address without error or error */ if (s == -1) { s = first; + } else if (s != first) { + /* Clean up the saved socket */ + ssh_connect_socket_close(first); } return s;