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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1920>
This commit is contained in:
Carlos Garnacho 2021-07-07 18:33:04 +02:00
parent 841ee0a227
commit 44af2c0d37

View File

@ -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