Index: libgdict/gdict-client-context.c
===================================================================
RCS file: /cvs/gnome/gnome-utils/gnome-dictionary/libgdict/gdict-client-context.c,v
retrieving revision 1.6
diff -u -r1.6 gdict-client-context.c
--- libgdict/gdict-client-context.c	11 Feb 2006 16:50:12 -0000	1.6
+++ libgdict/gdict-client-context.c	27 Mar 2006 11:50:47 -0000
@@ -1354,8 +1354,11 @@
           priv->command->state = S_DATA;
           
           p = g_utf8_strchr (buffer, -1, ' ');
-          if (p)
-            p = g_utf8_next_char (p);
+          if (!p)
+            break;
+          p = g_utf8_next_char (p);
+          if (!p)
+            break;
           
           gdict_debug ("server replied: %d databases found\n", atoi (p));
           
@@ -1379,8 +1382,9 @@
             break;
           
           p = g_utf8_strchr (name, -1, ' ');
-	  if (p)
-	    *p = '\0';
+	  if (!p)
+            break;
+	  *p = '\0';
 
 	  full = g_utf8_next_char (p);
           
@@ -1388,8 +1392,9 @@
             full = g_utf8_next_char (full);
           
           p = g_utf8_strchr (full, -1, '\"');
-          if (p)
-            *p = '\0';
+          if (!p)
+            break;
+          *p = '\0';
           
           db = _gdict_database_new (name);
           db->full_name = g_strdup (full);
@@ -1408,8 +1413,11 @@
           priv->command->state = S_DATA;
           
           p = g_utf8_strchr (buffer, -1, ' ');
-          if (p)
-            p = g_utf8_next_char (p);
+          if (!p)
+            break;
+          p = g_utf8_next_char (p);
+          if (!p)
+            break;
           
           gdict_debug ("server replied: %d strategies found\n", atoi (p));
           
@@ -1430,17 +1438,21 @@
             break;
           
 	  p = g_utf8_strchr (name, -1, ' ');
-          if (p)
-            *p = '\0';
+          if (!p)
+            break;
+          *p = '\0';
           
 	  desc = g_utf8_next_char (p);
+	  if (!desc)
+            break;
 	  
           if (desc[0] == '\"')
             desc = g_utf8_next_char (desc);
           
           p = g_utf8_strchr (desc, -1, '\"');
-          if (p)
-            *p = '\0';
+          if (!p)
+            break;
+          *p = '\0';
           
           strat = _gdict_strategy_new (name);
           strat->description = g_strdup (desc);
@@ -1460,8 +1472,11 @@
           priv->command->state = S_STATUS;
           
           p = g_utf8_strchr (buffer, -1, ' ');
-          if (p)
-            p = g_utf8_next_char (p);
+          if (!p)
+            break;
+          p = g_utf8_next_char (p);
+	  if (!p)
+            break;
           
           gdict_debug ("server replied: %d definitions found\n", atoi (p));
           
@@ -1482,15 +1497,20 @@
 
 	  /* skip the status code */
 	  word = g_utf8_strchr (word, -1, ' ');
+	  if (!word)
+            break;
 	  word = g_utf8_next_char (word);
+	  if (!word)
+            break;
           
           if (word[0] == '\"')
             word = g_utf8_next_char (word);
           
           p = g_utf8_strchr (word, -1, '\"');
-          if (p)
-            *p = '\0';
-          
+          if (!p)
+            break;
+	  *p = '\0';
+
 	  p = g_utf8_next_char (p);
 	  
           /* the database name is not protected by "" */
@@ -1499,10 +1519,13 @@
             break;
           
 	  p = g_utf8_strchr (db_name, -1, ' ');
-	  if (p)
-	    *p = '\0';
+	  if (!p)
+            break;
+	  *p = '\0';
 
 	  p = g_utf8_next_char (p);
+	  if (!p)
+            break;
 	  
           db_full = g_utf8_next_char (p);
           if (!db_full)
@@ -1512,8 +1535,9 @@
             db_full = g_utf8_next_char (db_full);
           
           p = g_utf8_strchr (db_full, -1, '\"');
-          if (p)
-            *p = '\0';
+          if (!p)
+            break;
+          *p = '\0';
           
           def = (GdictDefinition *) priv->command->data;
 
@@ -1576,8 +1600,11 @@
           priv->command->state = S_DATA;
           
           p = g_utf8_strchr (buffer, -1, ' ');
-          if (p)
-            p = g_utf8_next_char (p);
+          if (!p)
+            break;
+          p = g_utf8_next_char (p);
+          if (!p)
+            break;
           
           gdict_debug ("server replied: %d matches found\n", atoi (p));
 
@@ -1598,8 +1625,9 @@
             break;
           
           p = g_utf8_strchr (db_name, -1, ' ');
-          if (p)
-            *p = '\0';
+          if (!p)
+            break;
+          *p = '\0';
           
 	  word = g_utf8_next_char (p);
 	  
@@ -1607,8 +1635,9 @@
             word = g_utf8_next_char (word);
           
           p = g_utf8_strchr (word, -1, '\"');
-          if (p)
-            *p = '\0';
+          if (!p)
+            break;
+          *p = '\0';
           
           match = _gdict_match_new (word);
           match->database = g_strdup (db_name);
@@ -1633,7 +1662,7 @@
 {
   gchar *status;
   gint retval;
-  
+
   if (strlen (line) < 3)
     return 0;
   
@@ -1641,11 +1670,25 @@
       !g_unichar_isdigit (line[1]) ||
       !g_unichar_isdigit (line[2]))
     return 0;
-  
+
   status = g_strndup (line, 3);
   retval = atoi (status);
   g_free (status);
-  
+
+  if (retval == 110 || retval == 111 ||
+      retval == 150 || retval == 152)
+  {
+    gchar *p;
+    p = g_utf8_strchr (line, -1, ' ');
+    if (!p)
+      return 0;
+    p = g_utf8_next_char (p);
+    if (!p)
+      return 0;
+    if (!g_unichar_isdigit (p[0]))
+      return 0;
+  }
+
   return retval;
 }  
   
