[Commits] [SCM] claws branch, master, updated. 3.11.1-77-gc310c6b

holger at claws-mail.org holger at claws-mail.org
Sun Mar 15 19:20:31 CET 2015


The branch, master has been updated
       via  c310c6b9412613d7751b55f681f1748a22c42da3 (commit)
      from  897ba6486728b0917aa569e0f101d8a15fb380df (commit)

Summary of changes:
 src/plugins/gdata/cm_gdata_contacts.c |   29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)


- Log -----------------------------------------------------------------
commit c310c6b9412613d7751b55f681f1748a22c42da3
Author: Holger Berndt <hb at claws-mail.org>
Date:   Sun Mar 15 19:20:05 2015 +0100

    GData plugin: Harden against missing fields

diff --git a/src/plugins/gdata/cm_gdata_contacts.c b/src/plugins/gdata/cm_gdata_contacts.c
index fc48918..adc4400 100644
--- a/src/plugins/gdata/cm_gdata_contacts.c
+++ b/src/plugins/gdata/cm_gdata_contacts.c
@@ -56,6 +56,20 @@ CmGDataContactsCache contacts_cache;
 gboolean cm_gdata_contacts_query_running = FALSE;
 gchar *contacts_group_id = NULL;
 
+static void protect_fields_against_NULL(Contact *contact)
+{
+  g_return_if_fail(contact != NULL);
+
+  /* protect fields against being NULL */
+  if(contact->full_name == NULL)
+    contact->full_name = g_strdup("");
+  if(contact->given_name == NULL)
+    contact->given_name = g_strdup("");
+  if(contact->family_name == NULL)
+    contact->family_name = g_strdup("");
+}
+
+
 static void write_cache_to_file(void)
 {
   gchar *path;
@@ -139,6 +153,8 @@ static int add_gdata_contact_to_cache(GDataContactsContact *contact)
       cached_contact->family_name = g_strdup(gdata_gd_name_get_family_name(name));
       cached_contact->address = g_strdup(email_address);
 
+      protect_fields_against_NULL(cached_contact);
+
       contacts_cache.contacts = g_slist_prepend(contacts_cache.contacts, cached_contact);
 
       debug_print("GData plugin: Added %s <%s>\n", cached_contact->full_name, cached_contact->address);
@@ -496,8 +512,17 @@ void cm_gdata_load_contacts_cache_from_file(void)
             cached_contact->address = g_strdup(attr->value);
         }
       }
-      contacts_cache.contacts = g_slist_prepend(contacts_cache.contacts, cached_contact);
-      debug_print("Read contact from cache: %s\n", cached_contact->full_name);
+
+      if(cached_contact->address)
+      {
+        protect_fields_against_NULL(cached_contact);
+
+        contacts_cache.contacts = g_slist_prepend(contacts_cache.contacts, cached_contact);
+        debug_print("Read contact from cache: %s\n", cached_contact->full_name);
+      }
+      else {
+        debug_print("Ignored contact without email address: %s\n", cached_contact->full_name ? cached_contact->full_name : "(null)");
+      }
     }
   }
 

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list