[gnome-control-center] region: fix a crash when iterating locales



commit eb93004eadfc653122171ca7b26799948f15d5ad
Author: Cosimo Cecchi <cosimo endlessm com>
Date:   Fri Jan 9 18:47:46 2015 +0800

    region: fix a crash when iterating locales
    
    When iterating locales in the format chooser,
    gnome_get_country_from_locale() is called for each of them to build the
    locale label for the list row.
    
    The function creating the label doesn't take into account that
    gnome_get_country_from_locale() can return NULL, in which case it will
    both:
    - display an empty row in the list
    - crash when later trying to find a word in a NULL string with strstr()
      inside match_all()
    
    Just avoid creating a widget in that case.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742639

 panels/region/cc-format-chooser.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/panels/region/cc-format-chooser.c b/panels/region/cc-format-chooser.c
index 9d1dba5..5944781 100644
--- a/panels/region/cc-format-chooser.c
+++ b/panels/region/cc-format-chooser.c
@@ -224,6 +224,9 @@ region_widget_new (const gchar *locale_id,
         GtkWidget *check;
 
         locale_name = gnome_get_country_from_locale (locale_id, locale_id);
+        if (!locale_name)
+          return NULL;
+
         locale_current_name = gnome_get_country_from_locale (locale_id, NULL);
         locale_untranslated_name = gnome_get_country_from_locale (locale_id, "C");
 
@@ -307,6 +310,9 @@ add_regions (GtkDialog   *chooser,
 
                 is_initial = (g_hash_table_lookup (initial, locale_id) != NULL);
                 widget = region_widget_new (locale_id, !is_initial);
+                if (!widget)
+                  continue;
+
                 gtk_container_add (GTK_CONTAINER (priv->list), widget);
         }
 


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