summaryrefslogtreecommitdiffstats
path: root/examples/connect_ssh.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-04-14 14:16:58 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-04-14 14:19:08 +0200
commit1b44daddf6a7365e6c9a14b215032dc561a9f6bd (patch)
treec55bd7c6b4545a4bdfb50f9f3b5e54b1cd97e7d3 /examples/connect_ssh.c
parenta309c1b38e593dc28d09723251e9103c34157628 (diff)
downloadlibssh-1b44daddf6a7365e6c9a14b215032dc561a9f6bd.tar.gz
libssh-1b44daddf6a7365e6c9a14b215032dc561a9f6bd.tar.xz
libssh-1b44daddf6a7365e6c9a14b215032dc561a9f6bd.zip
examples: Call correct functions on exit.
(cherry picked from commit 3e7d4534cec141141e2b2cc5beedcc171cd99360)
Diffstat (limited to 'examples/connect_ssh.c')
-rw-r--r--examples/connect_ssh.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/connect_ssh.c b/examples/connect_ssh.c
index 90a2f34c..c9e4ef6e 100644
--- a/examples/connect_ssh.c
+++ b/examples/connect_ssh.c
@@ -32,22 +32,25 @@ ssh_session connect_ssh(const char *host, const char *user,int verbosity){
if(user != NULL){
if (ssh_options_set(session, SSH_OPTIONS_USER, user) < 0) {
- ssh_disconnect(session);
+ ssh_free(session);
return NULL;
}
}
if (ssh_options_set(session, SSH_OPTIONS_HOST, host) < 0) {
+ ssh_free(session);
return NULL;
}
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
if(ssh_connect(session)){
fprintf(stderr,"Connection failed : %s\n",ssh_get_error(session));
ssh_disconnect(session);
+ ssh_free(session);
return NULL;
}
if(verify_knownhost(session)<0){
ssh_disconnect(session);
+ ssh_free(session);
return NULL;
}
auth=authenticate_console(session);
@@ -59,5 +62,6 @@ ssh_session connect_ssh(const char *host, const char *user,int verbosity){
fprintf(stderr,"Error while authenticating : %s\n",ssh_get_error(session));
}
ssh_disconnect(session);
+ ssh_free(session);
return NULL;
}