client session BUGFIX memory leak
Fixes #148
diff --git a/src/session_client_ssh.c b/src/session_client_ssh.c
index 0d8d010..a2f3dbf 100644
--- a/src/session_client_ssh.c
+++ b/src/session_client_ssh.c
@@ -1829,6 +1829,7 @@
pw = getpwuid(getuid());
if (!pw) {
ERR("Unknown username for the SSH connection (%s).", strerror(errno));
+ ssh_free(sess);
return NULL;
}
ssh_options_set(sess, SSH_OPTIONS_USER, pw->pw_name);
@@ -1843,9 +1844,11 @@
#endif
session = _nc_connect_libssh(sess, ctx, &ssh_ch_opts, timeout);
- if (session) {
- session->flags |= NC_SESSION_CALLHOME;
+ if (!session) {
+ ssh_free(sess);
+ return NULL;
}
+ session->flags |= NC_SESSION_CALLHOME;
return session;
}