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
This commit is contained in:
Rui Matos 2011-07-23 22:58:06 +01:00
parent 385887c55b
commit 779ef582f1

View File

@ -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 */