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 f293659d5a
This commit is contained in:
Peter Hutterer 2023-11-30 15:05:51 +10:00
parent 0a951047f6
commit ae3eca18ce

View file

@ -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);