From acbdd0ecddc18d9fa7fc1634d4daf868ee0cd755 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 7 Feb 2025 18:14:55 +1000 Subject: [PATCH] mi: don't crash on miPointerGetPosition for disabled devices If a device is disabled, its master device is forcibly reset to NULL but unlike a floating device it doesn't have a sprite allocated. Calling miPointerGetPosition for a disabled device thus crashes. Avoid this by returning 0/0 for any device without a miPointer. This is a quick fix only, a proper fix for this issue is rather more involved. Closes #1782 Part-of: --- mi/mipointer.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mi/mipointer.c b/mi/mipointer.c index 53bd9327c..c9fda954f 100644 --- a/mi/mipointer.c +++ b/mi/mipointer.c @@ -726,8 +726,15 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, double *screenx, void miPointerGetPosition(DeviceIntPtr pDev, int *x, int *y) { - *x = MIPOINTER(pDev)->x; - *y = MIPOINTER(pDev)->y; + miPointerPtr pPointer = MIPOINTER(pDev); + if (pPointer) { + *x = pPointer->x; + *y = pPointer->y; + } + else { + *x = 0; + *y = 0; + } } /**