Xi: exevents: extra asserts on NULL pointers

Even though shouldn't be practically hit, better have some asserts,
giving us an idea of the point of cause, instead of segfaulting,
just in case.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-05-07 14:19:45 +02:00
parent cb69b80973
commit a48e2d8532

View File

@ -490,6 +490,7 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to)
if (!k->xkb_sli) if (!k->xkb_sli)
continue; continue;
if (k->xkb_sli->flags & XkbSLI_IsDefault) { if (k->xkb_sli->flags & XkbSLI_IsDefault) {
assert(to->key);
k->xkb_sli->names = to->key->xkbInfo->desc->names->indicators; k->xkb_sli->names = to->key->xkbInfo->desc->names->indicators;
k->xkb_sli->maps = to->key->xkbInfo->desc->indicators->maps; k->xkb_sli->maps = to->key->xkbInfo->desc->indicators->maps;
} }
@ -1043,6 +1044,7 @@ TouchClientWantsOwnershipEvents(ClientPtr client, DeviceIntPtr dev,
{ {
InputClients *iclient; InputClients *iclient;
assert(wOtherInputMasks(win));
nt_list_for_each_entry(iclient, wOtherInputMasks(win)->inputClients, next) { nt_list_for_each_entry(iclient, wOtherInputMasks(win)->inputClients, next) {
if (rClient(iclient) != client) if (rClient(iclient) != client)
continue; continue;
@ -1388,6 +1390,8 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
else else
evtype = GetXI2Type(ev->any.type); evtype = GetXI2Type(ev->any.type);
assert(iclients);
assert(wOtherInputMasks(*win));
nt_list_for_each_entry(iclients, nt_list_for_each_entry(iclients,
wOtherInputMasks(*win)->inputClients, next) wOtherInputMasks(*win)->inputClients, next)
if (xi2mask_isset(iclients->xi2mask, dev, evtype)) if (xi2mask_isset(iclients->xi2mask, dev, evtype))
@ -1402,6 +1406,7 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
int xi_type = GetXIType(TouchGetPointerEventType(ev)); int xi_type = GetXIType(TouchGetPointerEventType(ev));
Mask xi_filter = event_get_filter_from_type(dev, xi_type); Mask xi_filter = event_get_filter_from_type(dev, xi_type);
assert(wOtherInputMasks(*win));
nt_list_for_each_entry(iclients, nt_list_for_each_entry(iclients,
wOtherInputMasks(*win)->inputClients, next) wOtherInputMasks(*win)->inputClients, next)
if (iclients->mask[dev->id] & xi_filter) if (iclients->mask[dev->id] & xi_filter)
@ -2291,6 +2296,7 @@ RetrieveGestureDeliveryData(DeviceIntPtr dev, InternalEvent *ev, GestureListener
listener->type == GESTURE_LISTENER_REGULAR */ listener->type == GESTURE_LISTENER_REGULAR */
evtype = GetXI2Type(ev->any.type); evtype = GetXI2Type(ev->any.type);
assert(wOtherInputMasks(*win));
nt_list_for_each_entry(iclients, wOtherInputMasks(*win)->inputClients, next) nt_list_for_each_entry(iclients, wOtherInputMasks(*win)->inputClients, next)
if (xi2mask_isset(iclients->xi2mask, dev, evtype)) if (xi2mask_isset(iclients->xi2mask, dev, evtype))
break; break;
@ -2680,6 +2686,7 @@ SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client,
return BadAccess; return BadAccess;
} }
} }
assert(wOtherInputMasks(pWin));
for (others = wOtherInputMasks(pWin)->inputClients; others; for (others = wOtherInputMasks(pWin)->inputClients; others;
others = others->next) { others = others->next) {
if (SameClient(others, client)) { if (SameClient(others, client)) {
@ -3339,6 +3346,7 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
if (len && !others) { if (len && !others) {
if (AddExtensionClient(win, client, 0, 0) != Success) if (AddExtensionClient(win, client, 0, 0) != Success)
return BadAlloc; return BadAlloc;
assert(wOtherInputMasks(win));
others = wOtherInputMasks(win)->inputClients; others = wOtherInputMasks(win)->inputClients;
} }
@ -3348,6 +3356,7 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
} }
if (len) { if (len) {
assert(others);
xi2mask_set_one_mask(others->xi2mask, dev->id, mask, len); xi2mask_set_one_mask(others->xi2mask, dev->id, mask, len);
} }