wacom: check for the action type value

Action type comes from GSettings and may have been changed
to some invalid value, causing a segmentation fault in
control-center if the value is larger than the known action
types. This can also occur when downgrading from a version
with more possible actions.

Adds a sanity check to verify the given action type value
is within the bounds of the known action types.

https://bugzilla.gnome.org/show_bug.cgi?id=689265
This commit is contained in:
Olivier Fourdan 2012-11-29 11:58:18 +01:00 committed by Bastien Nocera
parent 3ecbd9b3e1
commit f5e8101dbd

View file

@ -613,6 +613,10 @@ add_button_to_store (GtkListStore *model,
dir_name = NULL;
}
/* Sanity check */
if (type >= G_N_ELEMENTS(action_table))
type = GSD_WACOM_ACTION_TYPE_NONE;
gtk_list_store_append (model, &new_row);
gtk_list_store_set (model, &new_row,
MAPPING_DESCRIPTION_COLUMN, dir_name ? dir_name : button->name,
@ -667,6 +671,10 @@ action_set_func (GtkTreeViewColumn *tree_column,
}
type = g_settings_get_enum (button->settings, ACTION_TYPE_KEY);
/* Sanity check */
if (type >= G_N_ELEMENTS(action_table))
type = GSD_WACOM_ACTION_TYPE_NONE;
g_object_set (cell,
"visible", TRUE,
"editable", TRUE,