From 0ca53c6908d1f07ad633707709f8fdd624fdfb86 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 2 Sep 2025 19:17:16 +0200 Subject: [PATCH] dix: ProcAllocColorCells(): use x_rpcbuf_t Use x_rpcbuf_t for payload assembly and X_SEND_REPLY_WITH_RPCBUF() for sending it all out. Signed-off-by: Enrico Weigelt, metux IT consult --- dix/dispatch.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 4512cc1bb..730d7b270 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -2684,14 +2684,17 @@ ProcAllocColorCells(ClientPtr client) } nmasks = stuff->planes; length = ((long) npixels + (long) nmasks) * sizeof(Pixel); - Pixel *ppixels = calloc(1, length); + + x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE }; + + Pixel *ppixels = x_rpcbuf_reserve(&rpcbuf, length); if (!ppixels) return BadAlloc; pmasks = ppixels + npixels; if ((rc = AllocColorCells(client, pcmp, npixels, nmasks, (Bool) stuff->contiguous, ppixels, pmasks))) { - free(ppixels); + x_rpcbuf_clear(&rpcbuf); return rc; } #ifdef XINERAMA @@ -2699,23 +2702,18 @@ ProcAllocColorCells(ClientPtr client) #endif /* XINERAMA */ { xAllocColorCellsReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = bytes_to_int32(length), .nPixels = npixels, .nMasks = nmasks }; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); swaps(&rep.nPixels); swaps(&rep.nMasks); SwapLongs(ppixels, length / 4); } - WriteToClient(client, sizeof(rep), &rep); - WriteToClient(client, length, ppixels); + + return X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf); } - free(ppixels); + x_rpcbuf_clear(&rpcbuf); return Success; } else {