From b619f19c84d4338c951cb8b1de5d7115a99b6c6e Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 17 Jul 2024 12:19:21 +0200 Subject: [PATCH] Xext: selinux: allocate reply buffer on stack Simplify reply buffer in SELinuxSendItemsToClient() by putting it on stack. No need to go through heap and free it later, if the compiler can do all the work for us. This also allows further generalizations of reply sending code by upcoming commits. Signed-off-by: Enrico Weigelt, metux IT consult --- Xext/xselinux_ext.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Xext/xselinux_ext.c b/Xext/xselinux_ext.c index e5c782d24..b00bd250d 100644 --- a/Xext/xselinux_ext.c +++ b/Xext/xselinux_ext.c @@ -348,10 +348,7 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items, int size, int count) { int rc = BadAlloc, k, pos = 0; - CARD32 *buf = calloc(size, sizeof(CARD32)); - if (size && !buf) { - goto out; - } + CARD32 buf[size]; if (!buf) // silence analyzer warning goto sendreply; @@ -398,11 +395,8 @@ sendreply: ; WriteToClient(client, size * 4, buf); /* Free stuff and return */ - rc = Success; - free(buf); - out: SELinuxFreeItems(items, count); - return rc; + return Success; } static int