[PATCH] Clear reused error variable



Hi,

vnc_connection_connect_socket reuses an error variable without clearing
it (issued by g_socket_connect in vnc_connection_connect_socket):

(gvncviewer:20406): GLib-WARNING **: GError set over the top of a previous GError or uninitialized memory.
This indicates a bug in someone's code. You must ensure an error is NULL before it's set.
The overwriting error message was: Connection in progress
Failed to connect to server

Attached patch fixes it for me.
Cheers,
 -- Guido

>From d94eae9beead12974e9190c56ad9f5de014ddfb8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx sigxcpu org>
Date: Tue, 7 Sep 2010 22:00:40 +0200
Subject: [PATCH] Clear error before reusing it

---
 src/vncconnection.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/vncconnection.c b/src/vncconnection.c
index ce2ad97..8a0a6c3 100644
--- a/src/vncconnection.c
+++ b/src/vncconnection.c
@@ -4610,6 +4610,7 @@ static gboolean vnc_connection_open_host_internal(VncConnection *conn)
 	while (!sock &&
 	       (sockaddr = g_socket_address_enumerator_next(enumerator, NULL, &conn_error))) {
 		VNC_DEBUG("Trying one socket");
+		g_clear_error(&conn_error);
 		sock = vnc_connection_connect_socket(sockaddr, &conn_error);
 		g_object_unref(sockaddr);
 	}
-- 
1.7.1



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