aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2011-03-13 00:15:59 +0100
committerDaniel Stenberg <daniel@haxx.se>2011-03-13 00:15:59 +0100
commit60172a0446bbe3f8bf1c7b066a03b7febfc96ceb (patch)
tree8da3ec0cded9704d67df84ab7235b35350f02396
parentc042340b2a8d503488a93e48b79878158606bd16 (diff)
SFTP: gracefully handle shutdown early
When using the multi interface and a handle using SFTP was removed very early on, we would get a segfault due to the code assumed data was there that hadn't yet been setup. Bug: http://curl.haxx.se/mail/lib-2011-03/0066.html Reported by: Saqib Ali
-rw-r--r--lib/ssh.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/ssh.c b/lib/ssh.c
index e67dbdd8e..434b80d06 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -2047,8 +2047,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
}
sshc->sftp_handle = NULL;
}
- Curl_safefree(sftp_scp->path);
- sftp_scp->path = NULL;
+ if(sftp_scp) {
+ Curl_safefree(sftp_scp->path);
+ sftp_scp->path = NULL;
+ }
DEBUGF(infof(data, "SFTP DONE done\n"));
#if 0 /* PREV */
@@ -2752,8 +2754,10 @@ static CURLcode ssh_done(struct connectdata *conn, CURLcode status)
else
result = status;
- Curl_safefree(sftp_scp->path);
- sftp_scp->path = NULL;
+ if(sftp_scp) {
+ Curl_safefree(sftp_scp->path);
+ sftp_scp->path = NULL;
+ }
Curl_pgrsDone(conn);
conn->data->req.keepon = 0; /* clear all bits */