From: Simon Tatham Date: Tue, 31 Jul 2001 14:23:21 +0000 (+0000) Subject: Yet another possible segfault path in the backends fixed. I don't X-Git-Tag: 0.52~266 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;ds=sidebyside;h=a4c1aad9b228d129b706924686072db7d4f791c4;p=PuTTY.git Yet another possible segfault path in the backends fixed. I don't _believe_ I'm still finding these. I have no idea what I was thinking when I wrote this stuff. [originally from svn r1162] --- diff --git a/raw.c b/raw.c index f5b93f79..86fd5315 100644 --- a/raw.c +++ b/raw.c @@ -23,8 +23,10 @@ static void c_write(char *buf, int len) static int raw_closing(Plug plug, char *error_msg, int error_code, int calling_back) { - sk_close(s); - s = NULL; + if (s) { + sk_close(s); + s = NULL; + } if (error_msg) { /* A socket error has occurred. */ connection_fatal(error_msg); diff --git a/rlogin.c b/rlogin.c index 3ae18089..80108527 100644 --- a/rlogin.c +++ b/rlogin.c @@ -24,8 +24,10 @@ static void c_write(char *buf, int len) static int rlogin_closing(Plug plug, char *error_msg, int error_code, int calling_back) { - sk_close(s); - s = NULL; + if (s) { + sk_close(s); + s = NULL; + } if (error_msg) { /* A socket error has occurred. */ connection_fatal(error_msg); diff --git a/ssh.c b/ssh.c index 45354884..e2c2d737 100644 --- a/ssh.c +++ b/ssh.c @@ -1478,8 +1478,10 @@ static int ssh_closing(Plug plug, char *error_msg, int error_code, int calling_back) { ssh_state = SSH_STATE_CLOSED; - sk_close(s); - s = NULL; + if (s) { + sk_close(s); + s = NULL; + } if (error_msg) { /* A socket error has occurred. */ connection_fatal(error_msg); diff --git a/telnet.c b/telnet.c index b00a6da0..04cbec02 100644 --- a/telnet.c +++ b/telnet.c @@ -565,8 +565,10 @@ static void do_telnet_read(char *buf, int len) static int telnet_closing(Plug plug, char *error_msg, int error_code, int calling_back) { - sk_close(s); - s = NULL; + if (s) { + sk_close(s); + s = NULL; + } if (error_msg) { /* A socket error has occurred. */ connection_fatal(error_msg);