mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 08:04:30 +00:00
Xext/xselinux: add fast path to ProcSELinuxListSelections()
If there's nothing to send, skip over a bunch of code to make a list that won't be used, and hopefully make the code path clearer to both humans and static analyzers, who raise errors as seen in https://gitlab.freedesktop.org/xorg/xserver/-/issues/1817 of dereferencing NULL pointers when count == 0. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2072>
This commit is contained in:
committed by
Enrico Weigelt
parent
5a8effe1e7
commit
c45edc0c51
@@ -451,8 +451,10 @@ ProcSELinuxListSelections(ClientPtr client)
|
||||
count = 0;
|
||||
for (pSel = CurrentSelections; pSel; pSel = pSel->next)
|
||||
count++;
|
||||
if (count == 0)
|
||||
return SELinuxSendItemsToClient(client, NULL, 0, 0);
|
||||
items = calloc(count, sizeof(SELinuxListItemRec));
|
||||
if (count && !items)
|
||||
if (!items)
|
||||
return BadAlloc;
|
||||
|
||||
/* Fill in the items and calculate size */
|
||||
|
||||
Reference in New Issue
Block a user