From 7fac611a3710ecb97614ddb74bf24ae8537e4038 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 (cherry picked from commit 15496a5e3d5407a2b480d8c726b012455f7898bb) 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 c6c96675d..c57d490bc 100644 --- a/dix/gestures.c +++ b/dix/gestures.c @@ -237,6 +237,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 ee581418a..44e615e0a 100644 --- a/dix/touch.c +++ b/dix/touch.c @@ -762,6 +762,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; @@ -779,6 +781,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;