From 15496a5e3d5407a2b480d8c726b012455f7898bb Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 11 Oct 2025 16:16:12 -0700 Subject: [PATCH] dix: avoid null dereference if wOtherInputMasks() returns NULL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wOtherInputMasks(win) macro will return NULL if win->optional is NULL. Reported in #1817: xwayland-24.1.6/redhat-linux-build/../dix/gestures.c:242:9: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘inputMasks’ xwayland-24.1.6/redhat-linux-build/../dix/touch.c:765:9: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘inputMasks’ xwayland-24.1.6/redhat-linux-build/../dix/touch.c:782:9: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘inputMasks’ Signed-off-by: Alan Coopersmith Part-of: --- dix/gestures.c | 1 + dix/touch.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/dix/gestures.c b/dix/gestures.c index 6b0f24728..4889a145a 100644 --- a/dix/gestures.c +++ b/dix/gestures.c @@ -234,6 +234,7 @@ GestureAddRegularListener(DeviceIntPtr dev, GestureInfoPtr gi, WindowPtr win, In return; inputMasks = wOtherInputMasks(win); + BUG_RETURN(!inputMasks); if (mask & EVENT_XI2_MASK) { nt_list_for_each_entry(iclients, inputMasks->inputClients, next) { diff --git a/dix/touch.c b/dix/touch.c index 7c509fb26..749454637 100644 --- a/dix/touch.c +++ b/dix/touch.c @@ -760,6 +760,8 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti, inputMasks = wOtherInputMasks(win); if (mask & EVENT_XI2_MASK) { + BUG_RETURN_VAL(!inputMasks, FALSE); + nt_list_for_each_entry(iclients, inputMasks->inputClients, next) { if (!xi2mask_isset(iclients->xi2mask, dev, evtype)) continue; @@ -777,6 +779,8 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti, int xitype = GetXIType(TouchGetPointerEventType(ev)); Mask xi_filter = event_get_filter_from_type(dev, xitype); + BUG_RETURN_VAL(!inputMasks, FALSE); + nt_list_for_each_entry(iclients, inputMasks->inputClients, next) { if (!(iclients->mask[dev->id] & xi_filter)) continue;