[gtk-vnc] Check if we have an error before reading or writing to the socket



commit 72ef54932f8e90e123f19fa1991820cb0b0cb458
Author: Jonh Wendell <jwendell gnome org>
Date:   Thu Sep 2 12:02:22 2010 -0300

    Check if we have an error before reading or writing to the socket
    
    If, in the middle of an operation the widget is destroyed, we
    should check the has_error variable otherwise we can try to
    read/write from/to an invalid socket.

 src/vncconnection.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/src/vncconnection.c b/src/vncconnection.c
index 736c94e..ce2ad97 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -604,6 +604,9 @@ static int vnc_connection_read_wire(VncConnection *conn, void *data, size_t len)
 	gboolean blocking = FALSE;
 
  reread:
+
+	if (priv->has_error) return -EINVAL;
+
 	if (priv->tls_session) {
 		ret = gnutls_read(priv->tls_session, data, len);
 		if (ret < 0) {
@@ -798,6 +801,8 @@ static void vnc_connection_flush_wire(VncConnection *conn,
 		int ret;
 		gboolean blocking = FALSE;
 
+		if (priv->has_error) return;
+
 		if (priv->tls_session) {
 			ret = gnutls_write(priv->tls_session,
 					   ptr+offset,



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