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 <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-17 12:19:21 +02:00
parent 8501dda10d
commit b619f19c84

View File

@ -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