[hotssh] channel: Add some preconditions around API requests



commit afb0cd5f4168981148217ed9b3d47a1ce8ceb899
Author: Colin Walters <walters verbum org>
Date:   Sun Dec 22 10:50:54 2013 -0500

    channel: Add some preconditions around API requests
    
    It's possible for apps to attempt to call into channels after the
    connection has closed; we should demote this to a precondition
    failure.

 libgssh/gssh-channel.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/libgssh/gssh-channel.c b/libgssh/gssh-channel.c
index 5bef3bf..b7e3d88 100644
--- a/libgssh/gssh-channel.c
+++ b/libgssh/gssh-channel.c
@@ -54,6 +54,8 @@ gssh_channel_close (GIOStream     *stream,
                       GError       **error)
 {
   GSshChannel *self = (GSshChannel*)stream;
+
+  g_return_val_if_fail (self->connection->state == GSSH_CONNECTION_STATE_CONNECTED, FALSE);
   
   if (self->connection)
     g_hash_table_remove (self->connection->channels, self);
@@ -128,6 +130,7 @@ gssh_channel_request_pty_size_async (GSshChannel         *self,
 {
   g_return_if_fail (self->have_pty);
   g_return_if_fail (self->pty_size_task == NULL);
+  g_return_if_fail (self->connection->state == GSSH_CONNECTION_STATE_CONNECTED);
 
   self->pty_size_task = g_task_new (self, cancellable, callback, user_data);
   self->pty_width = width;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]