Ensure our network layer is properly cleaned up before PuTTY exits.
[u/mdw/putty] / ssh.c
diff --git a/ssh.c b/ssh.c
index 270d76b..d03de08 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -1873,8 +1873,10 @@ static char *connect_to_host(char *host, int port, char **realhost, int nodelay)
        logevent(buf);
     }
     s = sk_new(addr, port, 0, 1, nodelay, &fn_table_ptr);
-    if ((err = sk_socket_error(s)))
+    if ((err = sk_socket_error(s))) {
+       s = NULL;
        return err;
+    }
 
 #ifdef FWHACK
     sk_write(s, "connect ", 8);
@@ -2166,8 +2168,7 @@ static int do_ssh1_login(unsigned char *in, int inlen, int ispkt)
                            break;
                          case 3:
                          case 4:
-                           random_save_seed();
-                           exit(0);
+                           cleanup_exit(0);
                            break;
                          default:
                            if (((c >= ' ' && c <= '~') ||
@@ -2472,8 +2473,7 @@ static int do_ssh1_login(unsigned char *in, int inlen, int ispkt)
                        break;
                      case 3:
                      case 4:
-                       random_save_seed();
-                       exit(0);
+                       cleanup_exit(0);
                        break;
                      default:
                        if (pos < sizeof(password)-1)
@@ -3971,8 +3971,7 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt)
                            break;
                          case 3:
                          case 4:
-                           random_save_seed();
-                           exit(0);
+                           cleanup_exit(0);
                            break;
                          default:
                            if (((c >= ' ' && c <= '~') ||
@@ -4450,8 +4449,7 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt)
                                break;
                              case 3:
                              case 4:
-                               random_save_seed();
-                               exit(0);
+                               cleanup_exit(0);
                                break;
                              default:
                                if (pos < sizeof(password)-1)