[Xfce4-commits] <xfce4-settings:xfce-4.8> Fix segfault if pointer has no feedback states and free memory.
Nick Schermer
noreply at xfce.org
Tue May 17 20:50:03 CEST 2011
Updating branch refs/heads/xfce-4.8
to 7d26aec0500ceac93bb9dbf150381375554a5a17 (commit)
from 645ad96fbf0dfa92928eb32fcec29824747e3677 (commit)
commit 7d26aec0500ceac93bb9dbf150381375554a5a17
Author: Nick Schermer <nick at xfce.org>
Date: Sat May 7 09:18:29 2011 +0200
Fix segfault if pointer has no feedback states and free memory.
(cherry picked from commit 1badff8a32e9d931ca266f37acf3eed48db90e46)
dialogs/mouse-settings/main.c | 33 ++++++++++++++++-----------------
1 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/dialogs/mouse-settings/main.c b/dialogs/mouse-settings/main.c
index 306a954..b3d0d9c 100644
--- a/dialogs/mouse-settings/main.c
+++ b/dialogs/mouse-settings/main.c
@@ -572,7 +572,7 @@ mouse_settings_device_selection_changed (GtkTreeSelection *selection,
gint nbuttons;
Display *xdisplay;
XDevice *device;
- XFeedbackState *states;
+ XFeedbackState *states, *pt;
gint nstates;
XPtrFeedbackState *state;
gint i;
@@ -634,28 +634,27 @@ mouse_settings_device_selection_changed (GtkTreeSelection *selection,
/* get the feedback states for this device */
states = XGetFeedbackControl (xdisplay, device, &nstates);
-
- /* intial values */
- acceleration = threshold = -1;
-
- /* get the pointer feedback class */
- for (i = 0; i < nstates; i++)
+ if (states != NULL)
{
- if (states->class == PtrFeedbackClass)
+ /* get the pointer feedback class */
+ for (pt = states, i = 0; i < nstates; i++)
{
- /* get the state */
- state = (XPtrFeedbackState *) states;
+ if (pt->class == PtrFeedbackClass)
+ {
+ /* get the state */
+ state = (XPtrFeedbackState *) pt;
+ acceleration = (gdouble) state->accelNum / (gdouble) state->accelDenom;
+ threshold = state->threshold;
- /* set values */
- acceleration = (gdouble) state->accelNum / (gdouble) state->accelDenom;
- threshold = state->threshold;
+ /* done */
+ break;
+ }
- /* done */
- break;
+ /* advance the offset */
+ pt = (XFeedbackState *) ((gchar *) pt + pt->length);
}
- /* advance the offset */
- states = (XFeedbackState *) ((gchar *) states + states->length);
+ XFreeFeedbackList (states);
}
/* close the device */
More information about the Xfce4-commits
mailing list