From 779ef582f140bab2eb4bcc53af0e27824004a6da Mon Sep 17 00:00:00 2001 From: Rui Matos Date: Sat, 23 Jul 2011 22:58:06 +0100 Subject: [PATCH] prefs: Initialize button_layout struct even on pref string corner cases We were leaving some members of the button_layout struct uninitialized if the pref string didn't have at least one colon or if it was an empty string (""). https://bugzilla.gnome.org/show_bug.cgi?id=654539 --- src/core/prefs.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/prefs.c b/src/core/prefs.c index 73d2fc336..2faf130f8 100644 --- a/src/core/prefs.c +++ b/src/core/prefs.c @@ -1679,6 +1679,7 @@ button_layout_handler (MetaPreference pref, if (string_value) sides = g_strsplit (string_value, ":", 2); + i = 0; if (sides != NULL && sides[0] != NULL) { char **buttons; @@ -1733,12 +1734,13 @@ button_layout_handler (MetaPreference pref, ++b; } - new_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST; - new_layout.left_buttons_has_spacer[i] = FALSE; - g_strfreev (buttons); } + new_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST; + new_layout.left_buttons_has_spacer[i] = FALSE; + + i = 0; if (sides != NULL && sides[0] != NULL && sides[1] != NULL) { char **buttons; @@ -1792,12 +1794,12 @@ button_layout_handler (MetaPreference pref, ++b; } - new_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST; - new_layout.right_buttons_has_spacer[i] = FALSE; - g_strfreev (buttons); } + new_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST; + new_layout.right_buttons_has_spacer[i] = FALSE; + g_strfreev (sides); /* Invert the button layout for RTL languages */