aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2015-03-25 10:18:22 -0500
committerCharles Kerr <charles.kerr@canonical.com>2015-03-25 10:18:22 -0500
commit1ef3f462a3cfde20fafdda7e53610a9858f88350 (patch)
tree6432036728c89249bb7bb67b79f0c5fddf6a8626 /src
parent4776ccea13253645e0ddd76d5550790dbfe02863 (diff)
downloadayatana-indicator-session-1ef3f462a3cfde20fafdda7e53610a9858f88350.tar.gz
ayatana-indicator-session-1ef3f462a3cfde20fafdda7e53610a9858f88350.tar.bz2
ayatana-indicator-session-1ef3f462a3cfde20fafdda7e53610a9858f88350.zip
in get_user_label(), don't dereference a NULL real_name pointer
Diffstat (limited to 'src')
-rw-r--r--src/service.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/service.c b/src/service.c
index 445f1af..5d2449e 100644
--- a/src/service.c
+++ b/src/service.c
@@ -295,12 +295,18 @@ get_user_label (const IndicatorSessionUser * user)
{
const char * c;
- /* If blank or whitespace, use username instead */
- for (c = user->real_name; *c != '\0' && g_ascii_isspace (*c); c++);
- if (*c == '\0')
- return user->user_name;
+ /* if real_name exists and isn't empty or whitespace, use it */
+ c = user->real_name;
+ if (c != NULL)
+ {
+ while ((*c != '\0') && g_ascii_isspace(*c)) /* walk past whitespace */
+ ++c;
+ if (*c != '\0')
+ return user->real_name;
+ }
- return user->real_name;
+ /* otherwise, use this as a fallback */
+ return user->user_name;
}
static const char *