[gnome-control-center] region: avoid a crash in the absence of configured layouts



commit 732ba22aec8f5843ce5d30472ea0b26ae7cf308f
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Aug 19 21:28:17 2011 -0400

    region: avoid a crash in the absence of configured layouts
    
    This code was creating a GString conditionally, but using
    it unconditionally afterwards. Instead of special-casing
    the str == NULL case, just always create it.

 panels/region/gnome-region-panel-system.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/panels/region/gnome-region-panel-system.c b/panels/region/gnome-region-panel-system.c
index 20e68f9..197ffb7 100644
--- a/panels/region/gnome-region-panel-system.c
+++ b/panels/region/gnome-region-panel-system.c
@@ -58,19 +58,17 @@ xkb_settings_changed (GSettings *settings,
 
 	if (g_str_equal (key, "layouts")) {
 		gint i;
-		GString *str = NULL;
+		GString *str = g_string_new ("");
 		gchar **layouts = g_settings_get_strv (settings, "layouts");
 
 		for (i = 0; i < G_N_ELEMENTS (layouts); i++) {
 			gchar *utf_visible = xkb_layout_description_utf8 (layouts[i]);
 
 			if (utf_visible != NULL) {
-				if (str != NULL) {
+				if (str->str[0] != '\0') {
 					str = g_string_append (str, ", ");
-					str = g_string_append (str, utf_visible);
-				} else
-					str = g_string_new (utf_visible);
-
+				}
+				str = g_string_append (str, utf_visible);
 				g_free (utf_visible);
 			}
 		}



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