mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
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:
committed by
Enrico Weigelt
parent
169a44fcd0
commit
51b5019fe2
42
Xext/xres.c
42
Xext/xres.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user