From 6a0c430b2505328a26f90e8635400b358a7777ab Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Wed, 11 Jun 2025 13:38:12 -0700 Subject: [PATCH] Revert "randr: ProcRRListOutputProperties(): use SwapShort()/SwapLong()" This reverts commit e3001b71b31b2cf1327fbc86e6403bc3db044409. Part-of: --- randr/rrproperty.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/randr/rrproperty.c b/randr/rrproperty.c index 610f5bb8d..122f5ab64 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -416,6 +416,7 @@ int ProcRRListOutputProperties(ClientPtr client) { REQUEST(xRRListOutputPropertiesReq); + Atom *pAtoms = NULL; int numProps = 0; RROutputPtr output; RRPropertyPtr prop; @@ -426,6 +427,9 @@ ProcRRListOutputProperties(ClientPtr client) for (prop = output->properties; prop; prop = prop->next) numProps++; + if (numProps) + if (!(pAtoms = xallocarray(numProps, sizeof(Atom)))) + return BadAlloc; xRRListOutputPropertiesReply rep = { .type = X_Reply, @@ -438,25 +442,18 @@ ProcRRListOutputProperties(ClientPtr client) swapl(&rep.length); swaps(&rep.nAtoms); } + WriteToClient(client, sizeof(xRRListOutputPropertiesReply), &rep); - Atom* pAtoms = calloc(sizeof(Atom), numProps); if (numProps) { - if (!pAtoms) - return BadAlloc; - /* Copy property name atoms to reply buffer */ Atom *temppAtoms = pAtoms; for (prop = output->properties; prop; prop = prop->next) *temppAtoms++ = prop->propertyName; - if (client->swapped) - SwapLongs(pAtoms, numProps); + client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; + WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms); + free(pAtoms); } - - WriteToClient(client, sizeof(xRRListOutputPropertiesReply), &rep); - WriteToClient(client, sizeof(Atom) * numProps, pAtoms); - free(pAtoms); - return Success; }