]> git.0d.be Git - empathy.git/commitdiff
contact_set_avatar_from_tp_contact: don't crash if we failed to load the avatar
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 22 Aug 2011 13:11:22 +0000 (15:11 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 22 Aug 2011 13:14:21 +0000 (15:14 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=656829

libempathy/empathy-contact.c

index eac5a8b84db3d1fa3e1d91ed2efad1396f173436..2058d4075855e8247d5c04fe08c7dccc94c41a09 100644 (file)
@@ -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);