diff options
-rw-r--r-- | ssh/client_proxy.c | 6 | ||||
-rw-r--r-- | ssh/sshnc.c | 2 | ||||
-rw-r--r-- | ssh/tomsg_clientlib.c | 2 |
3 files changed, 6 insertions, 4 deletions
diff --git a/ssh/client_proxy.c b/ssh/client_proxy.c index 1ce5e12..369ed0a 100644 --- a/ssh/client_proxy.c +++ b/ssh/client_proxy.c @@ -51,14 +51,14 @@ static void* proxy_thread_entry(void *thread_data_) { struct thread_data *thread_data = thread_data_; int client_sock = thread_data->client_sock; - struct sshnc_client *client; + struct sshnc_client *client = NULL; enum sshnc_retval ret = sshnc_connect( thread_data->server_host, thread_data->server_port, "tomsg", "tomsg", hostkey_checker, NULL, &client); if (ret != SSHNC_OK) { fprintf(stderr, "Could not connect over SSH: %s\n", sshnc_strerror(ret)); - return NULL; + goto cleanup; } struct pollfd polls[2]; @@ -137,7 +137,7 @@ static void* proxy_thread_entry(void *thread_data_) { cleanup: close(client_sock); - sshnc_close(client); + if (client) sshnc_close(client); return NULL; } diff --git a/ssh/sshnc.c b/ssh/sshnc.c index 872be2a..7d42de8 100644 --- a/ssh/sshnc.c +++ b/ssh/sshnc.c @@ -142,6 +142,8 @@ enum sshnc_retval sshnc_connect( void *userdata, struct sshnc_client **clientp // output ) { + *clientp = NULL; + clear_additional_error(); const ssh_session session = ssh_new(); diff --git a/ssh/tomsg_clientlib.c b/ssh/tomsg_clientlib.c index cf02208..c14d5c5 100644 --- a/ssh/tomsg_clientlib.c +++ b/ssh/tomsg_clientlib.c @@ -364,7 +364,7 @@ send_error_return: byte = sendret; writeall(thread_w, &byte, 1); free_client: - sshnc_close(conn); + if (conn) sshnc_close(conn); if (client) { if (client->buffer) free(client->buffer); if (client->inflight) free(client->inflight); |