From b5fd75a86067899ca9d656375dba88d3f656aa1e Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 17 Jul 2024 13:06:54 +0200 Subject: [PATCH] (!1601) Xext: xres: ProcXResQueryClientResources(): put temporary int array on stack Simplify allocaton by putting the small temporary int array onto stack. This also allows further simplifications by upcoming commits. The upper bound is determined by the number of resource types registered in the server - this can only be increased by writing new extensions. Signed-off-by: Enrico Weigelt, metux IT consult --- Xext/xres.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Xext/xres.c b/Xext/xres.c index 77148e004..83e99b1ce 100644 --- a/Xext/xres.c +++ b/Xext/xres.c @@ -292,7 +292,6 @@ ProcXResQueryClientResources(ClientPtr client) REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq); int i, clientID, num_types = 0; - int *counts; clientID = CLIENT_ID(stuff->xid); @@ -301,7 +300,8 @@ ProcXResQueryClientResources(ClientPtr client) return BadValue; } - counts = calloc(lastResourceType + 1, sizeof(int)); + int counts[lastResourceType + 1]; + memset(counts, 0, sizeof(counts)); FindAllClientResources(clients[clientID], ResFindAllRes, counts); @@ -342,8 +342,6 @@ ProcXResQueryClientResources(ClientPtr client) } } - free(counts); - return Success; }