[PATCH libevdev 4/7] Don't try setting an ABS code without data

Peter Hutterer peter.hutterer at who-t.net
Sun Jul 28 21:06:34 PDT 2013


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 libevdev/libevdev.c            | 2 ++
 test/test-libevdev-has-event.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/libevdev/libevdev.c b/libevdev/libevdev.c
index c517704..f83848a 100644
--- a/libevdev/libevdev.c
+++ b/libevdev/libevdev.c
@@ -854,6 +854,8 @@ libevdev_enable_event_code(struct libevdev *dev, unsigned int type,
 
 	if (type != EV_ABS && data != NULL)
 		return -1;
+	else if (type == EV_ABS && data == NULL)
+		return -1;
 
 	if (type == EV_SYN)
 		return 0;
diff --git a/test/test-libevdev-has-event.c b/test/test-libevdev-has-event.c
index 963952f..8a97b62 100644
--- a/test/test-libevdev-has-event.c
+++ b/test/test-libevdev-has-event.c
@@ -571,6 +571,8 @@ START_TEST(test_device_enable_bit_invalid)
 	ck_assert_int_eq(libevdev_enable_event_code(dev, EV_MAX + 1, ABS_MAX + 1, &abs), -1);
 	ck_assert_int_eq(libevdev_enable_event_type(dev, EV_MAX + 1), -1);
 
+	ck_assert_int_eq(libevdev_enable_event_code(dev, EV_ABS, ABS_Y, NULL), -1);
+
 	uinput_device_free(uidev);
 	libevdev_free(dev);
 }
-- 
1.8.2.1



More information about the Input-tools mailing list