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:
parent
8501dda10d
commit
b619f19c84
|
@ -348,10 +348,7 @@ SELinuxSendItemsToClient(ClientPtr client, SELinuxListItemRec * items,
|
||||||
int size, int count)
|
int size, int count)
|
||||||
{
|
{
|
||||||
int rc = BadAlloc, k, pos = 0;
|
int rc = BadAlloc, k, pos = 0;
|
||||||
CARD32 *buf = calloc(size, sizeof(CARD32));
|
CARD32 buf[size];
|
||||||
if (size && !buf) {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!buf) // silence analyzer warning
|
if (!buf) // silence analyzer warning
|
||||||
goto sendreply;
|
goto sendreply;
|
||||||
|
@ -398,11 +395,8 @@ sendreply: ;
|
||||||
WriteToClient(client, size * 4, buf);
|
WriteToClient(client, size * 4, buf);
|
||||||
|
|
||||||
/* Free stuff and return */
|
/* Free stuff and return */
|
||||||
rc = Success;
|
|
||||||
free(buf);
|
|
||||||
out:
|
|
||||||
SELinuxFreeItems(items, count);
|
SELinuxFreeItems(items, count);
|
||||||
return rc;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in New Issue