[gnome-control-center/gnome-3-36] user-account: don't segfault trying to get the user initials



commit 0c689f6a2bb29923f5c07814106a888f392a98bb
Author: Sebastien Bacher <seb128 ubuntu com>
Date:   Thu Aug 6 13:19:58 2020 +0200

    user-account: don't segfault trying to get the user initials
    
    it's possible that act_user_get_real_name returns null, handle that case
    fixes bug #959

 panels/user-accounts/user-utils.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/panels/user-accounts/user-utils.c b/panels/user-accounts/user-utils.c
index 68d8b61a4..ca3f7bd49 100644
--- a/panels/user-accounts/user-utils.c
+++ b/panels/user-accounts/user-utils.c
@@ -592,6 +592,8 @@ extract_initials_from_name (const gchar *name)
         gunichar unichar;
         gpointer q = NULL;
 
+        g_return_val_if_fail (name != NULL, NULL);
+
         p = g_utf8_strup (name, -1);
         normalized = g_utf8_normalize (g_strstrip (p), -1, G_NORMALIZE_DEFAULT_COMPOSE);
         if (normalized == NULL) {
@@ -748,10 +750,14 @@ set_user_icon_data (ActUser   *user,
 GdkPixbuf *
 generate_default_avatar (ActUser *user, gint size)
 {
+        const gchar *name;
         GdkPixbuf *pixbuf = NULL;
         cairo_surface_t *surface;
 
-        surface = generate_user_picture (act_user_get_real_name (user), size);
+        name = act_user_get_real_name (user);
+        if (name == NULL)
+                name = "";
+        surface = generate_user_picture (name, size);
 
         pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, size, size);
         cairo_surface_destroy (surface);


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