[gnome-control-center] Handle NULL usernames without crashing



commit 27dd815e8ab1547861199b5bdf919d852dcc1773
Author: William Jon McCann <jmccann redhat com>
Date:   Sat Oct 30 19:24:03 2010 -0400

    Handle NULL usernames without crashing

 panels/user-accounts/um-account-dialog.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/panels/user-accounts/um-account-dialog.c b/panels/user-accounts/um-account-dialog.c
index 3ad2d9c..6074adb 100644
--- a/panels/user-accounts/um-account-dialog.c
+++ b/panels/user-accounts/um-account-dialog.c
@@ -126,6 +126,10 @@ is_username_used (const gchar *username)
 {
         struct passwd *pwent;
 
+        if (username == NULL || username[0] == '\0') {
+                return FALSE;
+        }
+
         pwent = getpwnam (username);
 
         return pwent != NULL;
@@ -146,9 +150,15 @@ username_changed (GtkComboBoxText *combo,
 
         username = gtk_combo_box_text_get_active_text (combo);
 
-        in_use = is_username_used (username);
-        empty = username[0] == 0;
-        toolong = strlen (username) > MAXNAMELEN;
+        if (username == NULL || username[0] == '\0') {
+                empty = TRUE;
+                in_use = FALSE;
+                toolong = FALSE;
+        } else {
+                empty = FALSE;
+                in_use = is_username_used (username);
+                toolong = strlen (username) > MAXNAMELEN;
+        }
         valid = TRUE;
 
         if (!in_use && !empty && !toolong) {



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