Blob Blame History Raw
From 4e22d1a68e8ddcdea761fc51ea8c2ced0055fe60 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 3 Nov 2017 09:47:04 -0400
Subject: [PATCH 14/14] lib: fix crasher if accounts proxy is unavailable

Right now if the accounts proxy is unavailable act_user_get_real_name
crashes instead of returning NULL as advertised.

This commit makes it return NULL.

https://bugs.freedesktop.org/show_bug.cgi?id=103560
---
 src/libaccountsservice/act-user.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/libaccountsservice/act-user.c b/src/libaccountsservice/act-user.c
index 94884a1..a24f25a 100644
--- a/src/libaccountsservice/act-user.c
+++ b/src/libaccountsservice/act-user.c
@@ -520,60 +520,63 @@ set_is_loaded (ActUser  *user,
  *  freed, or %NULL.
  **/
 
 uid_t
 act_user_get_uid (ActUser *user)
 {
         g_return_val_if_fail (ACT_IS_USER (user), -1);
 
         if (user->accounts_proxy == NULL)
                 return -1;
 
         return accounts_user_get_uid (user->accounts_proxy);
 }
 
 /**
  * act_user_get_real_name:
  * @user: the user object to examine.
  *
  * Retrieves the display name of @user.
  *
  * Returns: (transfer none): a pointer to an array of characters which must not be modified or
  *  freed, or %NULL.
  **/
 const char *
 act_user_get_real_name (ActUser *user)
 {
         const char *real_name = NULL;
 
         g_return_val_if_fail (ACT_IS_USER (user), NULL);
 
+        if (user->accounts_proxy == NULL)
+                return NULL;
+
         real_name = accounts_user_get_real_name (user->accounts_proxy);
 
         if (real_name == NULL || real_name[0] == '\0') {
                 real_name = accounts_user_get_user_name (user->accounts_proxy);
         }
 
         return real_name;
 }
 
 /**
  * act_user_get_account_type:
  * @user: the user object to examine.
  *
  * Retrieves the account type of @user.
  *
  * Returns: a #ActUserAccountType
  **/
 ActUserAccountType
 act_user_get_account_type (ActUser *user)
 {
         g_return_val_if_fail (ACT_IS_USER (user), ACT_USER_ACCOUNT_TYPE_STANDARD);
 
         if (user->accounts_proxy == NULL)
                 return ACT_USER_ACCOUNT_TYPE_STANDARD;
 
         return accounts_user_get_account_type (user->accounts_proxy);
 }
 
 /**
  * act_user_get_password_mode:
-- 
2.14.2