36 lines
1.1 KiB
Diff
36 lines
1.1 KiB
Diff
From 5c8c310edb1e5dbf41c5d2d68622b63f7700488e Mon Sep 17 00:00:00 2001
|
|
From: Daniel Gustafsson <daniel@yesql.se>
|
|
Date: Fri, 26 Oct 2018 15:39:15 +0200
|
|
Subject: [PATCH 211/557] 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>
|
|
---
|
|
lib/ssh.c | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/lib/ssh.c b/lib/ssh.c
|
|
index a4b2ca4..da89619 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;
|
|
}
|
|
|
|
--
|
|
1.8.3.1
|
|
|