mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-02-21 09:50:36 +01: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 #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>
(cherry picked from commit d34243606c)
This commit is contained in:
parent
2b11d25e30
commit
449b317cd7
1 changed files with 3 additions and 1 deletions
|
|
@ -455,8 +455,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 */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue