summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2013-09-03 11:51:19 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2013-11-20 23:13:47 +0000
commitff5763c6e2044bcf355ef1026001e5e62726e0c2 (patch)
treea01be609530605abc0fc42c424aa98ca7fbc86a6
parent80d3fbdb9ca2e996cc66c25ff37ddfe43a18434e (diff)
downloadclutter-ff5763c6e2044bcf355ef1026001e5e62726e0c2.tar.gz
device: Guard against divisions by zero
The range of a device could be 0, so we need to bail out from the scaling during the axis translation. https://bugzilla.gnome.org/show_bug.cgi?id=707033 (cherry picked from commit fb8eacfb0256a211ca79366945c8f4eb4962be4e) Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
-rw-r--r--clutter/clutter-input-device.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/clutter/clutter-input-device.c b/clutter/clutter-input-device.c
index e92cf22a7..d2221772c 100644
--- a/clutter/clutter-input-device.c
+++ b/clutter/clutter-input-device.c
@@ -46,6 +46,8 @@
#include "clutter-private.h"
#include "clutter-stage-private.h"
+#include <math.h>
+
enum
{
PROP_0,
@@ -1199,6 +1201,9 @@ _clutter_input_device_translate_axis (ClutterInputDevice *device,
info->axis == CLUTTER_INPUT_AXIS_Y)
return FALSE;
+ if (fabs (info->max_value - info->min_value) < 0.0000001)
+ return FALSE;
+
width = info->max_value - info->min_value;
real_value = (info->max_axis * (value - info->min_value)
+ info->min_axis * (info->max_value - value))