From 44af2c0d37964997187b0295f15352b676f89840 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 7 Jul 2021 18:33:04 +0200 Subject: [PATCH] core: Be more careful around n_modes signedness This is returned as an integer, which we deal with as an unsigned integer. Deal with it as an integer all along, and skip safely negative values. Part-of: --- src/core/meta-pad-action-mapper.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/meta-pad-action-mapper.c b/src/core/meta-pad-action-mapper.c index e5331e1dd..7c78c4014 100644 --- a/src/core/meta-pad-action-mapper.c +++ b/src/core/meta-pad-action-mapper.c @@ -517,7 +517,7 @@ meta_pad_action_mapper_handle_button (MetaPadActionMapper *mapper, const ClutterPadButtonEvent *event) { GDesktopPadButtonAction action; - int button, group, mode; + int button, group, mode, n_modes = 0; gboolean is_press; GSettings *settings; char *accel; @@ -531,9 +531,11 @@ meta_pad_action_mapper_handle_button (MetaPadActionMapper *mapper, group = clutter_input_device_get_mode_switch_button_group (pad, button); is_press = event->type == CLUTTER_PAD_BUTTON_PRESS; - if (is_press && group >= 0) + if (group >= 0) + n_modes = clutter_input_device_get_group_n_modes (pad, group); + + if (is_press && n_modes > 0) { - guint n_modes = clutter_input_device_get_group_n_modes (pad, group); const char *pretty_name = NULL; PadMappingInfo *info; #ifdef HAVE_LIBWACOM