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; }