[empathy] contact_set_avatar_from_tp_contact: don't crash if we failed to load the avatar



commit f60338e75ad72300e1f93ea38ce17284d50d698c
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Mon Aug 22 15:11:22 2011 +0200

    contact_set_avatar_from_tp_contact: don't crash if we failed to load the avatar
    
    https://bugzilla.gnome.org/show_bug.cgi?id=656829

 libempathy/empathy-contact.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index eac5a8b..2058d40 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -1811,8 +1811,17 @@ contact_set_avatar_from_tp_contact (EmpathyContact *contact)
       gchar *data;
       gsize len;
       gchar *path;
+      GError *error = NULL;
+
+      if (!g_file_load_contents (file, NULL, &data, &len, NULL, &error))
+        {
+          DEBUG ("Failed to load avatar: %s", error->message);
+
+          g_error_free (error);
+          contact_set_avatar (contact, NULL);
+          return;
+        }
 
-      g_file_load_contents (file, NULL, &data, &len, NULL, NULL);
       path = g_file_get_path (file);
 
       avatar = empathy_avatar_new ((guchar *) data, len, mime, path);



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