From 118a747acd1151e45dcf3eb154d48814209a2214 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Mon, 11 Aug 2025 15:49:32 +0200 Subject: [PATCH] socket: Free poll handle when resetting socket state Since 07cb0be12 we are not closing the user provided FDs, but the above change also resulted in memory leak during ssh_disconnect that left the poll_handle allocated during reset. Signed-off-by: Jakub Jelen Reviewed-by: Andreas Schneider --- src/socket.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/socket.c b/src/socket.c index c06dae5a..a31a4bfe 100644 --- a/src/socket.c +++ b/src/socket.c @@ -202,7 +202,10 @@ void ssh_socket_reset(ssh_socket s) s->read_wontblock = 0; s->write_wontblock = 0; s->data_except = 0; - s->poll_handle = NULL; + if (s->poll_handle != NULL) { + ssh_poll_free(s->poll_handle); + s->poll_handle = NULL; + } s->state=SSH_SOCKET_NONE; #ifndef _WIN32 s->proxy_pid = 0;