aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Aguirre <albaguirre@gmail.com>2018-02-26 10:16:01 -0600
committerAndreas Schneider <asn@cryptomilk.org>2018-03-07 15:48:04 +0100
commit85ab4ee53a59d2883a5d0e41ad76d0ed9fbd9fca (patch)
tree8edde999077f7acce615f2b427e2d0a8405619df
parent25f31760aacde37493c21a8cfc4446093413d146 (diff)
downloadlibssh-85ab4ee53a59d2883a5d0e41ad76d0ed9fbd9fca.tar.gz
libssh-85ab4ee53a59d2883a5d0e41ad76d0ed9fbd9fca.tar.xz
libssh-85ab4ee53a59d2883a5d0e41ad76d0ed9fbd9fca.zip
connector: ensure channel callbacks are removed
ssh_connector_free fails to remove the in/out channel callbacks as ssh_connector_remove_event sets the in/out channel variables to NULL. Have ssh_connector_free, remove the channel callbacks first before invoking ssh_connector_remove_event. Signed-off-by: Alberto Aguirre <albaguirre@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--src/connector.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/connector.c b/src/connector.c
index 565e3100..ac29635e 100644
--- a/src/connector.c
+++ b/src/connector.c
@@ -106,6 +106,15 @@ ssh_connector ssh_connector_new(ssh_session session)
void ssh_connector_free (ssh_connector connector)
{
+ if (connector->in_channel != NULL) {
+ ssh_remove_channel_callbacks(connector->in_channel,
+ &connector->in_channel_cb);
+ }
+ if (connector->out_channel != NULL) {
+ ssh_remove_channel_callbacks(connector->out_channel,
+ &connector->out_channel_cb);
+ }
+
if (connector->event != NULL){
ssh_connector_remove_event(connector);
}
@@ -120,15 +129,6 @@ void ssh_connector_free (ssh_connector connector)
connector->out_poll = NULL;
}
- if (connector->in_channel != NULL) {
- ssh_remove_channel_callbacks(connector->in_channel,
- &connector->in_channel_cb);
- }
- if (connector->out_channel != NULL) {
- ssh_remove_channel_callbacks(connector->out_channel,
- &connector->out_channel_cb);
- }
-
free(connector);
}