From 2e052969057bdecfdc23c0e8b1dccb8ad00d6799 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 13 May 2025 13:46:18 +0200 Subject: [PATCH] randr: no need to for local temp buffer in ProcRRQueryProviderProperty() The code can be much simpler by just using CopySwap32Write(). And we also don't need the callback in WriteSwappedDataToClient(), just call the corresponding write function directly. This also makes some analyzer warnings go away. Signed-off-by: Enrico Weigelt, metux IT consult --- randr/rrproviderproperty.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/randr/rrproviderproperty.c b/randr/rrproviderproperty.c index 11d986b33..84bb724e0 100644 --- a/randr/rrproviderproperty.c +++ b/randr/rrproviderproperty.c @@ -380,7 +380,6 @@ ProcRRQueryProviderProperty(ClientPtr client) REQUEST(xRRQueryProviderPropertyReq); RRProviderPtr provider; RRPropertyPtr prop; - char *extra = NULL; REQUEST_SIZE_MATCH(xRRQueryProviderPropertyReq); @@ -390,12 +389,6 @@ ProcRRQueryProviderProperty(ClientPtr client) if (!prop) return BadName; - if (prop->num_valid) { - extra = xallocarray(prop->num_valid, sizeof(INT32)); - if (!extra) - return BadAlloc; - } - xRRQueryProviderPropertyReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, @@ -410,11 +403,10 @@ ProcRRQueryProviderProperty(ClientPtr client) } WriteToClient(client, sizeof(xRRQueryProviderPropertyReply), (char *) &rep); if (prop->num_valid) { - memcpy(extra, prop->valid_values, prop->num_valid * sizeof(INT32)); - client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; - WriteSwappedDataToClient(client, prop->num_valid * sizeof(INT32), - extra); - free(extra); + if (client->swapped) + CopySwap32Write(client, prop->num_valid * sizeof(INT32), (CARD32*)prop->valid_values); + else + WriteToClient(client, prop->num_valid * sizeof(INT32), prop->valid_values); } return Success; }