[RFC PATCH xf86-input-libinput] Do not crash if the device is invalid

Olivier Fourdan ofourdan at redhat.com
Tue Feb 24 06:43:14 PST 2015


https://bugs.freedesktop.org/show_bug.cgi?id=89296

Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
---
 src/libinput.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/libinput.c b/src/libinput.c
index 9613fbd..3159373 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -1304,6 +1304,9 @@ LibinputSetPropertyTap(DeviceIntPtr dev,
 	struct libinput_device *device = driver_data->device;
 	BOOL* data;
 
+	if (device == NULL)
+		return XI_BadDevice;
+
 	if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
 		return BadMatch;
 
@@ -1332,6 +1335,9 @@ LibinputSetPropertyCalibration(DeviceIntPtr dev,
 	struct libinput_device *device = driver_data->device;
 	float* data;
 
+	if (device == NULL)
+		return XI_BadDevice;
+
 	if (val->format != 32 || val->size != 9 || val->type != prop_float)
 		return BadMatch;
 
@@ -1365,6 +1371,9 @@ LibinputSetPropertyAccel(DeviceIntPtr dev,
 	struct libinput_device *device = driver_data->device;
 	float* data;
 
+	if (device == NULL)
+		return XI_BadDevice;
+
 	if (val->format != 32 || val->size != 1 || val->type != prop_float)
 		return BadMatch;
 
@@ -1394,6 +1403,9 @@ LibinputSetPropertyNaturalScroll(DeviceIntPtr dev,
 	struct libinput_device *device = driver_data->device;
 	BOOL* data;
 
+	if (device == NULL)
+		return XI_BadDevice;
+
 	if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
 		return BadMatch;
 
@@ -1424,6 +1436,9 @@ LibinputSetPropertySendEvents(DeviceIntPtr dev,
 	BOOL* data;
 	uint32_t modes = 0;
 
+	if (device == NULL)
+		return XI_BadDevice;
+
 	if (val->format != 8 || val->size != 2 || val->type != XA_INTEGER)
 		return BadMatch;
 
@@ -1459,6 +1474,9 @@ LibinputSetPropertyLeftHanded(DeviceIntPtr dev,
 	struct libinput_device *device = driver_data->device;
 	BOOL* data;
 
+	if (device == NULL)
+		return XI_BadDevice;
+
 	if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
 		return BadMatch;
 
@@ -1489,6 +1507,9 @@ LibinputSetPropertyScrollMethods(DeviceIntPtr dev,
 	BOOL* data;
 	uint32_t modes = 0;
 
+	if (device == NULL)
+		return XI_BadDevice;
+
 	if (val->format != 8 || val->size != 3 || val->type != XA_INTEGER)
 		return BadMatch;
 
@@ -1527,6 +1548,9 @@ LibinputSetPropertyScrollButton(DeviceIntPtr dev,
 	struct libinput_device *device = driver_data->device;
 	CARD32* data;
 
+	if (device == NULL)
+		return XI_BadDevice;
+
 	if (val->format != 32 || val->size != 1 || val->type != XA_CARDINAL)
 		return BadMatch;
 
-- 
2.1.0



More information about the xorg-devel mailing list