aboutsummaryrefslogtreecommitdiff
path: root/lib/ssh.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2009-10-18 01:11:25 +0000
committerDaniel Stenberg <daniel@haxx.se>2009-10-18 01:11:25 +0000
commit86cec97b2214cefdbc7cfa1c434c5823b28a47c3 (patch)
treeb95ba6368a6898a8c809ba60d7ca116792f83b37 /lib/ssh.c
parente5ee82274535366632343f80ea5ca5556b056486 (diff)
- Fixed memory leak in the SCP/SFTP code as it never freed the knownhosts
data!
Diffstat (limited to 'lib/ssh.c')
-rw-r--r--lib/ssh.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/ssh.c b/lib/ssh.c
index 1503734eb..eaaa8e69a 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -2204,6 +2204,13 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
case SSH_SESSION_FREE:
+#ifdef HAVE_LIBSSH2_KNOWNHOST_API
+ if(sshc->kh) {
+ libssh2_knownhost_free(sshc->kh);
+ sshc->kh = NULL;
+ }
+#endif
+
if(sshc->ssh_session) {
rc = libssh2_session_free(sshc->ssh_session);
if(rc == LIBSSH2_ERROR_EAGAIN) {
@@ -2565,11 +2572,12 @@ static CURLcode ssh_do(struct connectdata *conn, bool *done)
static CURLcode scp_disconnect(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
+ struct ssh_conn *ssh = &conn->proto.sshc;
Curl_safefree(conn->data->state.proto.ssh);
conn->data->state.proto.ssh = NULL;
- if(conn->proto.sshc.ssh_session) {
+ if(ssh->ssh_session) {
/* only if there's a session still around to use! */
state(conn, SSH_SESSION_DISCONNECT);