Xext: xres: fix XResQueryClientResources request

been using the wrong index for retrieving the resource type atom.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2025-08-25 17:25:45 +02:00
committed by Enrico Weigelt
parent 169a44fcd0
commit 51b5019fe2

View File

@@ -304,12 +304,28 @@ ProcXResQueryClientResources(ClientPtr client)
FindAllClientResources(resClient, ResFindAllRes, counts);
int num_types = 0;
for (int i = 0; i <= lastResourceType; i++) {
if (counts[i])
num_types++;
xXResType *scratch = calloc(lastResourceType + 1, sizeof(xXResType));
if (!scratch) {
free(counts);
return BadAlloc;
}
int num_types = 0;
for (int i = 0; i < num_types; i++) {
if (!(counts[i]))
continue;
scratch[num_types].resource_type = resourceTypeAtom(i + 1);
scratch[num_types].count = counts[i];
if (client->swapped) {
swapl(&scratch[num_types].resource_type);
swapl(&scratch[num_types].count);
}
num_types++;
}
free(counts);
xXResQueryClientResourcesReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
@@ -322,24 +338,6 @@ ProcXResQueryClientResources(ClientPtr client)
swapl(&rep.num_types);
}
xXResType *scratch = calloc(sizeof(xXResType), num_types);
if (!scratch) {
free(counts);
return BadAlloc;
}
for (int i = 0; i < num_types; i++) {
scratch[i].resource_type = resourceTypeAtom(i + 1);
scratch[i].count = counts[i];
if (client->swapped) {
swapl(&scratch[i].resource_type);
swapl(&scratch[i].count);
}
}
free(counts);
WriteToClient(client, sizeof(xXResQueryClientResourcesReply), &rep);
WriteToClient(client, num_types * sizeof(xXResType), scratch);
free(scratch);