[vinagre] Check for NULL strings in strcmp



commit a712f56578084d11a954bd1d5250a84a2c778ab9
Author: Jonh Wendell <jwendell gnome org>
Date:   Tue Sep 22 16:06:26 2009 -0300

    Check for NULL strings in strcmp

 vinagre/vinagre-window.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/vinagre/vinagre-window.c b/vinagre/vinagre-window.c
index a7c240c..e008710 100644
--- a/vinagre/vinagre-window.c
+++ b/vinagre/vinagre-window.c
@@ -992,21 +992,31 @@ VinagreTab *
 vinagre_window_conn_exists (VinagreWindow *window, VinagreConnection *conn)
 {
   VinagreConnection *c;
-  VinagreTab *tab = NULL;
+  VinagreTab *tab;
+  const gchar *host, *protocol;
+  gint port;
   GList *l;
 
   g_return_val_if_fail (VINAGRE_IS_WINDOW (window), NULL);
   g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn), NULL);
 
+  host = vinagre_connection_get_host (conn);
+  protocol = vinagre_connection_get_protocol (conn);
+  port = vinagre_connection_get_port (conn);
+
+  if (!host || !protocol)
+    return NULL;
+
   l = vinagre_window_get_connections (window);
+  tab = NULL;
 
   while (l != NULL)
     {
       c = VINAGRE_CONNECTION (l->data);
 
-      if (!strcmp (vinagre_connection_get_host (conn), vinagre_connection_get_host (c)) &&
-	  vinagre_connection_get_port (conn) == vinagre_connection_get_port (c) &&
-	  vinagre_connection_get_protocol (conn) == vinagre_connection_get_protocol (c))
+      if (!strcmp (host, vinagre_connection_get_host (c)) &&
+	  !strcmp (protocol, vinagre_connection_get_protocol (c)) &&
+	  port == vinagre_connection_get_port (c))
 	{
 	  tab = g_object_get_data (G_OBJECT (c), VINAGRE_TAB_KEY);
 	  break;



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