summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gustafsson <daniel@yesql.se>2018-10-26 15:39:15 +0200
committerDaniel Gustafsson <daniel@yesql.se>2018-10-26 15:39:15 +0200
commit5c8c310edb1e5dbf41c5d2d68622b63f7700488e (patch)
tree1a632e1c7280eb26ada180e17183d13a796766ee
parenta0c2779d613f76a16e49aeba9a199c6d33c168b3 (diff)
downloadgnurl-5c8c310edb1e5dbf41c5d2d68622b63f7700488e.tar.gz
gnurl-5c8c310edb1e5dbf41c5d2d68622b63f7700488e.tar.bz2
gnurl-5c8c310edb1e5dbf41c5d2d68622b63f7700488e.zip
ssh: free the session on init failures
Ensure to clear the session object in case the libssh2 initialization fails. It could be argued that the libssh2 error function should be called to get a proper error message in this case. But since the only error path in libssh2_knownhost_init() is memory a allocation failure it's safest to avoid since the libssh2 error handling allocates memory. Closes #3179 Reviewed-by: Daniel Stenberg <daniel@haxx.se>
-rw-r--r--lib/ssh.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/ssh.c b/lib/ssh.c
index a4b2ca43a..da896196f 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -2926,7 +2926,7 @@ static CURLcode ssh_connect(struct connectdata *conn, bool *done)
int rc;
ssh->kh = libssh2_knownhost_init(ssh->ssh_session);
if(!ssh->kh) {
- /* eeek. TODO: free the ssh_session! */
+ libssh2_session_free(ssh->ssh_session);
return CURLE_FAILED_INIT;
}