diff options
author | José Expósito <jose.exposito89@gmail.com> | 2022-10-03 12:53:22 +0200 |
---|---|---|
committer | José Expósito <jose.exposito89@gmail.com> | 2022-10-03 12:53:22 +0200 |
commit | 640208531c5bd1765201ce65d2a83ae082e0271d (patch) | |
tree | 1ce8d7bf36fad6b3c3a868d96bfd0a546326a7bf | |
parent | 7d29e2d61628655d85f78bdad728af9676a17942 (diff) | |
download | libinput-640208531c5bd1765201ce65d2a83ae082e0271d.tar.gz |
tablet: avoid errors calling libevdev_get_abs_info()
Commit 806d4a1393db ("tablet: check libevdev_get_abs_info() return
value") prevented a crash when tilt was deactivated by a quirk.
For more information check [1].
Add similar checks before calling libevdev_get_abs_info() to avoid
possible crashes.
[1] https://gitlab.freedesktop.org/libinput/libinput/-/issues/805
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
-rw-r--r-- | src/evdev-tablet.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index 6094bd53..68c3c3e4 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -455,6 +455,10 @@ tablet_update_xy(struct tablet_dispatch *tablet, const struct input_absinfo *absinfo; int value; + if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_X) || + !libevdev_has_event_code(device->evdev, EV_ABS, ABS_Y)) + return; + if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_X) || bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_Y)) { absinfo = libevdev_get_abs_info(device->evdev, ABS_X); @@ -528,6 +532,9 @@ tablet_update_pressure(struct tablet_dispatch *tablet, { const struct input_absinfo *absinfo; + if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_PRESSURE)) + return; + if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_PRESSURE)) { absinfo = libevdev_get_abs_info(device->evdev, ABS_PRESSURE); @@ -541,6 +548,9 @@ tablet_update_distance(struct tablet_dispatch *tablet, { const struct input_absinfo *absinfo; + if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_DISTANCE)) + return; + if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_DISTANCE)) { absinfo = libevdev_get_abs_info(device->evdev, ABS_DISTANCE); @@ -554,6 +564,9 @@ tablet_update_slider(struct tablet_dispatch *tablet, { const struct input_absinfo *absinfo; + if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_WHEEL)) + return; + if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_SLIDER)) { absinfo = libevdev_get_abs_info(device->evdev, ABS_WHEEL); @@ -597,6 +610,9 @@ tablet_update_artpen_rotation(struct tablet_dispatch *tablet, { const struct input_absinfo *absinfo; + if (!libevdev_has_event_code(device->evdev, EV_ABS, ABS_Z)) + return; + if (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z)) { absinfo = libevdev_get_abs_info(device->evdev, |