From d7d92c68bd5c76525752feab65c44b3157deb7f1 Mon Sep 17 00:00:00 2001 From: Jason Gerecke Date: Fri, 4 Oct 2024 10:19:35 -0700 Subject: [PATCH] backends/x11: Avoid potential crash in pad_switch_mode The meta_input_device_get_wacom_device function may return NULL, so we should check it before use. I'm not 100% sure that the code as currently written could reach here with a NULL wacom_device, but that could change in the future. Part-of: --- src/backends/x11/meta-input-device-x11.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backends/x11/meta-input-device-x11.c b/src/backends/x11/meta-input-device-x11.c index 32aa9b4a3..7bc089eb7 100644 --- a/src/backends/x11/meta-input-device-x11.c +++ b/src/backends/x11/meta-input-device-x11.c @@ -737,6 +737,10 @@ pad_switch_mode (ClutterInputDevice *device, wacom_device = meta_input_device_get_wacom_device (META_INPUT_DEVICE (device)); + + if (!wacom_device) + return FALSE; + n_buttons = libwacom_get_num_buttons (wacom_device); for (i = 0; i < n_buttons; i++)