diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-04-03 12:50:17 +0000 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-04-03 12:50:17 +0000 |
commit | b5eb33bb69c9d5331b6f6c1cc922976c36c1d299 (patch) | |
tree | 8b6abb739cd50ac7fbf09eadda6a965a01639816 /libssh/session.c | |
parent | 2791ce7e01f9e177d3bd4c49ff2400b04ce9a399 (diff) | |
download | libssh-b5eb33bb69c9d5331b6f6c1cc922976c36c1d299.tar.gz libssh-b5eb33bb69c9d5331b6f6c1cc922976c36c1d299.tar.xz libssh-b5eb33bb69c9d5331b6f6c1cc922976c36c1d299.zip |
Improve ssh_socket_free().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@381 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/session.c')
-rw-r--r-- | libssh/session.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/libssh/session.c b/libssh/session.c index 4a623bfd..972dc29b 100644 --- a/libssh/session.c +++ b/libssh/session.c @@ -41,6 +41,7 @@ */ SSH_SESSION *ssh_new(void) { SSH_SESSION *session; + session = malloc(sizeof (SSH_SESSION)); if (session == NULL) { return NULL; @@ -87,28 +88,23 @@ err: return NULL; } -void ssh_cleanup(SSH_SESSION *session){ - int i; - enter_function(); +void ssh_cleanup(SSH_SESSION *session) { + int i; + enter_function(); + + if (session == NULL) { + return; + } - if(session->serverbanner) - free(session->serverbanner); - if(session->clientbanner) - free(session->clientbanner); - if(session->in_buffer) - buffer_free(session->in_buffer); - if(session->out_buffer) - buffer_free(session->out_buffer); - if(session->banner) - free(session->banner); - if(session->options) - ssh_options_free(session->options); - if(session->current_crypto) - crypto_free(session->current_crypto); - if(session->next_crypto) - crypto_free(session->next_crypto); - if(session->socket) - ssh_socket_free(session->socket); + SAFE_FREE(session->serverbanner); + SAFE_FREE(session->clientbanner); + SAFE_FREE(session->banner); + buffer_free(session->in_buffer); + buffer_free(session->out_buffer); + crypto_free(session->current_crypto); + crypto_free(session->next_crypto); + ssh_socket_free(session->socket); + ssh_options_free(session->options); // delete all channels while(session->channels) channel_free(session->channels); |