From: simon 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-Url: https://git.distorted.org.uk/u/mdw/putty/commitdiff_plain/f3ab576e6a5f34dfedde93fe236d1eac577628d0 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. git-svn-id: svn://svn.tartarus.org/sgt/putty@1162 cda61777-01e9-0310-a592-d414129be87e --- 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);