From 74a98066621d216f5f0c629dcb61e22256b5a82b Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 25 Apr 2003 17:44:09 +0000 Subject: [PATCH] The new ssh_do_close() function itself causes a segfault if the connection goes foom before ssh->channels is set up. Oops. Fixed. git-svn-id: svn://svn.tartarus.org/sgt/putty@3141 cda61777-01e9-0310-a592-d414129be87e --- ssh.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/ssh.c b/ssh.c index 4243a049..669f26ba 100644 --- a/ssh.c +++ b/ssh.c @@ -2051,19 +2051,21 @@ static void ssh_do_close(Ssh ssh) * Now we must shut down any port and X forwardings going * through this connection. */ - for (i = 0; NULL != (c = index234(ssh->channels, i)); i++) { - switch (c->type) { - case CHAN_X11: - x11_close(c->u.x11.s); - break; - case CHAN_SOCKDATA: - pfd_close(c->u.pfd.s); - break; + if (ssh->channels) { + for (i = 0; NULL != (c = index234(ssh->channels, i)); i++) { + switch (c->type) { + case CHAN_X11: + x11_close(c->u.x11.s); + break; + case CHAN_SOCKDATA: + pfd_close(c->u.pfd.s); + break; + } + del234(ssh->channels, c); + if (ssh->version == 2) + bufchain_clear(&c->v.v2.outbuffer); + sfree(c); } - del234(ssh->channels, c); - if (ssh->version == 2) - bufchain_clear(&c->v.v2.outbuffer); - sfree(c); } } -- 2.11.0