Use the array size for checking the validity of request numbers
instead of hard-coded constants. Suggested by Julien Cristau.
This commit is contained in:
parent
90f7a9841a
commit
e03328b4d1
@ -49,6 +49,7 @@ SOFTWARE.
|
|||||||
* Dispatch routines and initialization routines for the X input extension.
|
* Dispatch routines and initialization routines for the X input extension.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#define ARRAY_SIZE(_a) (sizeof((_a)) / sizeof((_a)[0]))
|
||||||
|
|
||||||
#define NUMTYPES 15
|
#define NUMTYPES 15
|
||||||
|
|
||||||
@ -410,7 +411,7 @@ static int
|
|||||||
ProcIDispatch(ClientPtr client)
|
ProcIDispatch(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xReq);
|
REQUEST(xReq);
|
||||||
if (stuff->data > (IREQUESTS + XI2REQUESTS) || !ProcIVector[stuff->data])
|
if (stuff->data > ARRAY_SIZE(ProcIVector) || !ProcIVector[stuff->data])
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
|
|
||||||
return (*ProcIVector[stuff->data])(client);
|
return (*ProcIVector[stuff->data])(client);
|
||||||
@ -429,7 +430,7 @@ static int
|
|||||||
SProcIDispatch(ClientPtr client)
|
SProcIDispatch(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xReq);
|
REQUEST(xReq);
|
||||||
if (stuff->data > (IREQUESTS + XI2REQUESTS) || !SProcIVector[stuff->data])
|
if (stuff->data > ARRAY_SIZE(SProcIVector) || !SProcIVector[stuff->data])
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
|
|
||||||
return (*SProcIVector[stuff->data])(client);
|
return (*SProcIVector[stuff->data])(client);
|
||||||
|
Loading…
Reference in New Issue
Block a user