diff --git a/dix/devices.c b/dix/devices.c index 839de35aa..207b78b87 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -1890,6 +1890,7 @@ ProcGetPointerMapping(ClientPtr client) * the ClientPointer could change. */ DeviceIntPtr ptr = PickPointer(client); ButtonClassPtr butc = ptr->button; + int nElts; int rc; REQUEST_SIZE_MATCH(xReq); @@ -1898,15 +1899,16 @@ ProcGetPointerMapping(ClientPtr client) if (rc != Success) return rc; + nElts = (butc) ? butc->numButtons : 0; rep = (xGetPointerMappingReply) { .type = X_Reply, - .nElts = (butc) ? butc->numButtons : 0, + .nElts = nElts, .sequenceNumber = client->sequence, - .length = ((unsigned) rep.nElts + (4 - 1)) / 4 + .length = ((unsigned) nElts + (4 - 1)) / 4 }; WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep); if (butc) - WriteToClient(client, (int) rep.nElts, &butc->map[1]); + WriteToClient(client, nElts, &butc->map[1]); return Success; }