common: Fix crashes for incomplete locales

By ignoring locales without language codes, or territory.

https://bugzilla.gnome.org/show_bug.cgi?id=658551
This commit is contained in:
Bastien Nocera 2012-03-01 17:54:13 +00:00
parent 242bb93610
commit e3c3380fea

View file

@ -620,7 +620,6 @@ count_languages_and_territories (void)
{
gpointer value;
GHashTableIter iter;
gint count;
gdm_language_count_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
gdm_territory_count_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
@ -631,13 +630,21 @@ count_languages_and_territories (void)
locale = (GdmLocale *) value;
count = GPOINTER_TO_INT (g_hash_table_lookup (gdm_language_count_map, locale->language_code));
count++;
g_hash_table_insert (gdm_language_count_map, g_strdup (locale->language_code), GINT_TO_POINTER (count));
if (locale->language_code != NULL) {
int count;
count = GPOINTER_TO_INT (g_hash_table_lookup (gdm_territory_count_map, locale->territory_code));
count++;
g_hash_table_insert (gdm_territory_count_map, g_strdup (locale->territory_code), GINT_TO_POINTER (count));
count = GPOINTER_TO_INT (g_hash_table_lookup (gdm_language_count_map, locale->language_code));
count++;
g_hash_table_insert (gdm_language_count_map, g_strdup (locale->language_code), GINT_TO_POINTER (count));
}
if (locale->territory_code != NULL) {
int count;
count = GPOINTER_TO_INT (g_hash_table_lookup (gdm_territory_count_map, locale->territory_code));
count++;
g_hash_table_insert (gdm_territory_count_map, g_strdup (locale->territory_code), GINT_TO_POINTER (count));
}
}
}