From 85ab4ee53a59d2883a5d0e41ad76d0ed9fbd9fca Mon Sep 17 00:00:00 2001 From: Alberto Aguirre Date: Mon, 26 Feb 2018 10:16:01 -0600 Subject: [PATCH] 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 Reviewed-by: Andreas Schneider --- src/connector.c | 18 +++++++++--------- 1 file 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); }