Commit 6f7ecb05 authored by Sean Davis's avatar Sean Davis 🕶

Prevent potential illegal memory access, move null pointer check to before dereference

parent e0f9a220
......@@ -167,8 +167,8 @@ cb_toolbar_style_combo_changed (GtkComboBox *combo)
{
gint active;
/* Get active item, prevent number outside the array */
active = CLAMP (gtk_combo_box_get_active (combo), 0, (gint) G_N_ELEMENTS (toolbar_styles_array));
/* Get active item, prevent number outside the array (stay within zero-index) */
active = CLAMP (gtk_combo_box_get_active (combo), 0, (gint) G_N_ELEMENTS (toolbar_styles_array)-1);
/* Save setting */
xfconf_channel_set_string (xsettings_channel, "/Gtk/ToolbarStyle", toolbar_styles_array[active]);
......@@ -194,8 +194,8 @@ cb_hinting_style_combo_changed (GtkComboBox *combo)
{
gint active;
/* Get active item, prevent number outside the array */
active = CLAMP (gtk_combo_box_get_active (combo), 0, (gint) G_N_ELEMENTS (xft_hint_styles_array));
/* Get active item, prevent number outside the array (stay within zero-index) */
active = CLAMP (gtk_combo_box_get_active (combo), 0, (gint) G_N_ELEMENTS (xft_hint_styles_array)-1);
/* Save setting */
xfconf_channel_set_string (xsettings_channel, "/Xft/HintStyle", xft_hint_styles_array[active]);
......@@ -206,8 +206,8 @@ cb_rgba_style_combo_changed (GtkComboBox *combo)
{
gint active;
/* Get active item, prevent number outside the array */
active = CLAMP (gtk_combo_box_get_active (combo), 0, (gint) G_N_ELEMENTS (xft_rgba_array));
/* Get active item, prevent number outside the array (stay within zero-index) */
active = CLAMP (gtk_combo_box_get_active (combo), 0, (gint) G_N_ELEMENTS (xft_rgba_array)-1);
/* Save setting */
xfconf_channel_set_string (xsettings_channel, "/Xft/RGBA", xft_rgba_array[active]);
......
......@@ -1568,6 +1568,10 @@ mouse_settings_device_populate_store (GtkBuilder *builder,
|| g_str_has_prefix (device_info->name, "Virtual core XTEST"))
continue;
/* cannot go any further without device name */
if (device_info->name == NULL)
continue;
/* create a valid xfconf device name */
xfconf_name = mouse_settings_device_xfconf_name (device_info->name);
......@@ -1579,8 +1583,7 @@ mouse_settings_device_populate_store (GtkBuilder *builder,
-1);
/* check if we should select this device */
if (device_info->name != NULL
&& opt_device_name != NULL
if (opt_device_name != NULL
&& strcmp (opt_device_name, device_info->name) == 0)
{
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment