[Xfce4-commits] [xfce/xfce4-settings] 01/01: Prevent potential illegal memory access, move null pointer check to before dereference
noreply at xfce.org
noreply at xfce.org
Sat Feb 7 04:12:30 CET 2015
This is an automated email from the git hooks/post-receive script.
bluesabre pushed a commit to branch master
in repository xfce/xfce4-settings.
commit 6f7ecb05c9e6227375638fd94b12a10d0a59abc2
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Fri Feb 6 22:12:26 2015 -0500
Prevent potential illegal memory access, move null pointer check to before dereference
---
dialogs/appearance-settings/main.c | 12 ++++++------
dialogs/mouse-settings/main.c | 7 +++++--
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/dialogs/appearance-settings/main.c b/dialogs/appearance-settings/main.c
index b8b676a..81a3fdc 100644
--- a/dialogs/appearance-settings/main.c
+++ b/dialogs/appearance-settings/main.c
@@ -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]);
diff --git a/dialogs/mouse-settings/main.c b/dialogs/mouse-settings/main.c
index 1942612..3516a95 100644
--- a/dialogs/mouse-settings/main.c
+++ b/dialogs/mouse-settings/main.c
@@ -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);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list