ssh->mainchan can be NULL; try not to segfault in that situation.
[sgt/putty] / ssh.c
diff --git a/ssh.c b/ssh.c
index 1127c5c..a2aeb54 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -183,7 +183,7 @@ static const char *const ssh2_disconnect_reasons[] = {
 /*
  * Codes for terminal modes.
  * Most of these are the same in SSH-1 and SSH-2.
- * This list is derived from draft-ietf-secsh-connect-25 and
+ * This list is derived from RFC 4254 and
  * SSH-1 RFC-1.2.31.
  */
 static const struct {
@@ -663,7 +663,7 @@ static void ssh_special(void *handle, Telnet_Special);
 static int ssh2_try_send(struct ssh_channel *c);
 static void ssh2_add_channel_data(struct ssh_channel *c, char *buf, int len);
 static void ssh_throttle_all(Ssh ssh, int enable, int bufsize);
-static void ssh2_set_window(struct ssh_channel *c, unsigned newwin);
+static void ssh2_set_window(struct ssh_channel *c, int newwin);
 static int ssh_sendbuffer(void *handle);
 static int ssh_do_close(Ssh ssh, int notify_exit);
 static unsigned long ssh_pkt_getuint32(struct Packet *pkt);
@@ -6172,7 +6172,7 @@ static void ssh2_try_send_and_unthrottle(struct ssh_channel *c)
 /*
  * Potentially enlarge the window on an SSH-2 channel.
  */
-static void ssh2_set_window(struct ssh_channel *c, unsigned newwin)
+static void ssh2_set_window(struct ssh_channel *c, int newwin)
 {
     Ssh ssh = c->ssh;
 
@@ -9082,8 +9082,9 @@ static void ssh_unthrottle(void *handle, int bufsize)
            ssh1_throttle(ssh, -1);
        }
     } else {
-       ssh2_set_window(ssh->mainchan,
-                       ssh->mainchan->v.v2.locmaxwin - bufsize);
+       if (ssh->mainchan)
+           ssh2_set_window(ssh->mainchan,
+                           ssh->mainchan->v.v2.locmaxwin - bufsize);
     }
 }