[gnome-settings-daemon] keyboard: Don't crash on invalid LANG



commit 6119a23abeaefda4774d6d71648168c6904cca89
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jun 14 15:31:09 2012 +0100

    keyboard: Don't crash on invalid LANG

 plugins/keyboard/gsd-keyboard-manager.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c
index aac01e9..bcf008c 100644
--- a/plugins/keyboard/gsd-keyboard-manager.c
+++ b/plugins/keyboard/gsd-keyboard-manager.c
@@ -73,6 +73,8 @@
 
 #define INPUT_SOURCE_TYPE_XKB "xkb"
 
+#define DEFAULT_LANGUAGE "en_US"
+
 struct GsdKeyboardManagerPrivate
 {
 	guint      start_idle_id;
@@ -324,10 +326,13 @@ replace_layout_and_variant (GsdKeyboardManager *manager,
         locale = setlocale (LC_MESSAGES, NULL);
         /* If LANG is empty, default to en_US */
         if (!locale)
-                language = g_strdup ("en_US");
+                language = g_strdup (DEFAULT_LANGUAGE);
         else
                 language = language_code_from_locale (locale);
 
+        if (!language)
+                language = language_code_from_locale (DEFAULT_LANGUAGE);
+
         gnome_xkb_info_get_layout_info_for_language (manager->priv->xkb_info,
                                                      language,
                                                      NULL,



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