From 16d6182e15ecba0cc3a53e87d9acc6d7cf1928fc Mon Sep 17 00:00:00 2001 From: sesankm <26676400+sesankm@users.noreply.github.com> Date: Mon, 8 Sep 2025 21:22:06 -0500 Subject: [PATCH] glx: glxcmds: use rpcbuf for payload in __glXDisp_QueryExtensionsString Signed-off-by: sesankm <26676400+sesankm@users.noreply.github.com> --- glx/glxcmds.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 81fc203afe..ecd4e1f3eb 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -2327,43 +2327,26 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc) ClientPtr client = cl->client; xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *) pc; __GLXscreen *pGlxScreen; - size_t n, length; - char *buf; int err; if (!validGlxScreen(client, req->screen, &pGlxScreen, &err)) return err; - n = strlen(pGlxScreen->GLXextensions) + 1; - length = __GLX_PAD(n) >> 2; - + /* client expects payload to contain a null terminated string + * and uses this header to determine how many bytes to process */ + size_t n = strlen(pGlxScreen->GLXextensions) + 1; xGLXQueryExtensionsStringReply reply = { - .type = X_Reply, - .sequenceNumber = client->sequence, - .length = length, .n = n }; - /* Allocate buffer to make sure it's a multiple of 4 bytes big. */ - buf = calloc(length, 4); - if (buf == NULL) - return BadAlloc; - memcpy(buf, pGlxScreen->GLXextensions, n); - if (client->swapped) { - swaps(&reply.sequenceNumber); - swapl(&reply.length); swapl(&reply.n); - WriteToClient(client, sizeof(xGLXQueryExtensionsStringReply), &reply); - WriteToClient(client, length << 2, buf); - } - else { - WriteToClient(client, sizeof(xGLXQueryExtensionsStringReply), &reply); - WriteToClient(client, (int) (length << 2), buf); } - free(buf); - return Success; + x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE }; + + x_rpcbuf_write_string_0t_pad(&rpcbuf, pGlxScreen->GLXextensions); + return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf); } #ifndef GLX_VENDOR_NAMES_EXT