[gnome-initial-setup/shell/4765: 176/362] keyboard: ignore locales without a language name
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/shell/4765: 176/362] keyboard: ignore locales without a language name
- Date: Thu, 19 Mar 2015 01:35:52 +0000 (UTC)
commit 9bee4a3db9a884aaac464d890124c7d73766c70c
Author: Mario Sanchez Prada <mario endlessm com>
Date: Wed Aug 27 12:55:56 2014 +0100
keyboard: ignore locales without a language name
Adding to the internal hash table every language returned by
gnome_get_all_locales() without checking if they have a non-NULL visual
name to display will cause a crash when trying to use the search box,
since the call to strstr() in match_all, called from list_filter() will
segfault with the NULL string.
To avoid this issue, we just check early if there's an untranslated
name available for the locale in get_locale_infos(), not adding it to
the internal hash table and continuing to the next one if not the case.
[endlessm/eos-shell#3480]
.../pages/keyboard/cc-input-chooser.c | 23 ++++++++++---------
1 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/gnome-initial-setup/pages/keyboard/cc-input-chooser.c
b/gnome-initial-setup/pages/keyboard/cc-input-chooser.c
index 077be91..d96f21d 100644
--- a/gnome-initial-setup/pages/keyboard/cc-input-chooser.c
+++ b/gnome-initial-setup/pages/keyboard/cc-input-chooser.c
@@ -1014,7 +1014,7 @@ get_locale_infos (GtkWidget *chooser)
{
gchar *lang_code, *country_code;
gchar *simple_locale;
- gchar *tmp;
+ gchar *untranslated_locale;
const gchar *type = NULL;
const gchar *id = NULL;
@@ -1023,20 +1023,19 @@ get_locale_infos (GtkWidget *chooser)
simple_locale = g_strdup_printf ("%s_%s.utf8", lang_code, country_code);
if (g_hash_table_contains (priv->locales, simple_locale))
- {
- g_free (simple_locale);
- g_free (country_code);
- g_free (lang_code);
- continue;
- }
+ goto free_and_continue;
+
+ /* We are not interested in locales whose name we can't display */
+ untranslated_locale = gnome_get_language_from_locale (simple_locale, "C");
+ if (!untranslated_locale)
+ goto free_and_continue;
info = g_new0 (LocaleInfo, 1);
- info->id = simple_locale; /* Take ownership */
+ info->id = g_strdup (simple_locale);
info->name = gnome_get_language_from_locale (simple_locale, NULL);
info->unaccented_name = cc_util_normalize_casefold_and_unaccent (info->name);
- tmp = gnome_get_language_from_locale (simple_locale, "C");
- info->untranslated_name = cc_util_normalize_casefold_and_unaccent (tmp);
- g_free (tmp);
+ info->untranslated_name = cc_util_normalize_casefold_and_unaccent (untranslated_locale);
+ g_free (untranslated_locale);
g_hash_table_replace (priv->locales, simple_locale, info);
add_locale_to_table (priv->locales_by_language, lang_code, info);
@@ -1064,8 +1063,10 @@ get_locale_infos (GtkWidget *chooser)
add_ids_to_set (layouts_with_locale, list);
g_list_free (list);
+ free_and_continue:
g_free (lang_code);
g_free (country_code);
+ g_free (simple_locale);
}
g_strfreev (locale_ids);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]