xext: xres: protect from allocation failure

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-02-24 13:49:22 +01:00
parent dda64fcadf
commit 01d6efb414

View File

@ -221,12 +221,13 @@ ProcXResQueryClients(ClientPtr client)
{ {
/* REQUEST(xXResQueryClientsReq); */ /* REQUEST(xXResQueryClientsReq); */
xXResQueryClientsReply rep; xXResQueryClientsReply rep;
int *current_clients;
int i, num_clients; int i, num_clients;
REQUEST_SIZE_MATCH(xXResQueryClientsReq); REQUEST_SIZE_MATCH(xXResQueryClientsReq);
current_clients = calloc(currentMaxClients, sizeof(int)); int *current_clients = calloc(currentMaxClients, sizeof(int));
if (!current_clients)
return BadAlloc;
num_clients = 0; num_clients = 0;
for (i = 0; i < currentMaxClients; i++) { for (i = 0; i < currentMaxClients; i++) {
@ -303,7 +304,6 @@ ProcXResQueryClientResources(ClientPtr client)
REQUEST(xXResQueryClientResourcesReq); REQUEST(xXResQueryClientResourcesReq);
xXResQueryClientResourcesReply rep; xXResQueryClientResourcesReply rep;
int i, num_types; int i, num_types;
int *counts;
REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq); REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq);
@ -316,7 +316,9 @@ ProcXResQueryClientResources(ClientPtr client)
return BadValue; return BadValue;
} }
counts = calloc(lastResourceType + 1, sizeof(int)); int *counts = calloc(lastResourceType + 1, sizeof(int));
if (!counts)
return BadAlloc;
FindAllClientResources(resClient, ResFindAllRes, counts); FindAllClientResources(resClient, ResFindAllRes, counts);