From ae3eca18cec44a953789c7f77ffab888713ed132 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 30 Nov 2023 15:05:51 +1000 Subject: [PATCH] Fix _XkbReadGetDeviceInfoReply for nButtons == dev->buttons XkbGetDeviceInfo(dpy, XkbXI_ButtonActionsMask, 2, 0, 0) always returns NULL because the number of buttons on the device equals (unsurpisingly) the number of buttons requested (i.e. first + nBtns == dev->nbuttons). This currently causes it to bail out and return NULL. Fixes f293659d5a4024bda386305bb7ebeb4647c40934 --- src/xkb/XKBExtDev.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/xkb/XKBExtDev.c b/src/xkb/XKBExtDev.c index a3e671df..162cc356 100644 --- a/src/xkb/XKBExtDev.c +++ b/src/xkb/XKBExtDev.c @@ -188,8 +188,7 @@ _XkbReadGetDeviceInfoReply(Display *dpy, return tmp; } if (rep->nBtnsWanted > 0) { - if (((unsigned short) rep->firstBtnWanted + rep->nBtnsWanted) - >= devi->num_btns) + if (((unsigned short) rep->firstBtnWanted + rep->nBtnsWanted) > devi->num_btns) goto BAILOUT; act = &devi->btn_acts[rep->firstBtnWanted]; bzero((char *) act, (rep->nBtnsWanted * sizeof(XkbAction))); @@ -201,8 +200,7 @@ _XkbReadGetDeviceInfoReply(Display *dpy, if (rep->nBtnsRtrn > 0) { int size; - if (((unsigned short) rep->firstBtnRtrn + rep->nBtnsRtrn) - >= devi->num_btns) + if (((unsigned short) rep->firstBtnRtrn + rep->nBtnsRtrn) > devi->num_btns) goto BAILOUT; act = &devi->btn_acts[rep->firstBtnRtrn]; size = rep->nBtnsRtrn * SIZEOF(xkbActionWireDesc);