connect: Close possibly leaking socket

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit c36bd2304a)
This commit is contained in:
Jakub Jelen
2025-12-16 17:22:27 +01:00
parent 20d78046aa
commit 463665db9d

View File

@@ -281,6 +281,9 @@ socket_t ssh_connect_host_nonblocking(ssh_session session, const char *host,
* connection, otherwise return the first address without error or error */ * connection, otherwise return the first address without error or error */
if (s == -1) { if (s == -1) {
s = first; s = first;
} else if (s != first) {
/* Clean up the saved socket */
ssh_connect_socket_close(first);
} }
return s; return s;