[gnome-settings-daemon] keyboard: Don't crash if LANG is empty



commit 76e527cfb81544773e21eeb746e0a01325692c14
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jun 14 15:19:01 2012 +0100

    keyboard: Don't crash if LANG is empty
    
    Use en_US as the fallback locale if LANG isn't set.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=678100

 plugins/keyboard/gsd-keyboard-manager.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c
index fc51013..aac01e9 100644
--- a/plugins/keyboard/gsd-keyboard-manager.c
+++ b/plugins/keyboard/gsd-keyboard-manager.c
@@ -318,8 +318,15 @@ replace_layout_and_variant (GsdKeyboardManager *manager,
         const gchar *latin_variant = "";
         const gchar *locale_layout = NULL;
         const gchar *locale_variant = NULL;
-        const gchar *locale = setlocale (LC_MESSAGES, NULL);
-        gchar *language = language_code_from_locale (locale);
+        const gchar *locale;
+        gchar *language;
+
+        locale = setlocale (LC_MESSAGES, NULL);
+        /* If LANG is empty, default to en_US */
+        if (!locale)
+                language = g_strdup ("en_US");
+        else
+                language = language_code_from_locale (locale);
 
         gnome_xkb_info_get_layout_info_for_language (manager->priv->xkb_info,
                                                      language,



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