X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/d27916ce6dc22fd1280edd4bc0c835d8f17b0581..133ff7fb94934ff7857a23aea35892561968f1b7:/portfwd.c diff --git a/portfwd.c b/portfwd.c index 264198fb..00cff5ee 100644 --- a/portfwd.c +++ b/portfwd.c @@ -87,7 +87,17 @@ static int pfd_closing(Plug plug, const char *error_msg, int error_code, /* * Socket error. Slam the connection instantly shut. */ - sshfwd_unclean_close(pr->c); + if (pr->c) { + sshfwd_unclean_close(pr->c); + } else { + /* + * We might not have an SSH channel, if a socket error + * occurred during SOCKS negotiation. If not, we must + * clean ourself up without sshfwd_unclean_close's call + * back to pfd_close. + */ + pfd_close(pr->s); + } } else { /* * Ordinary EOF received on socket. Send an EOF on the SSH