mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-05-05 13:28:08 +02:00
Xext/xselinux: avoid memory leak in SELinuxAtomToSID()
Reported in #1817:
xwayland-24.1.6/redhat-linux-build/../Xext/xselinux_label.c:142:13: warning[-Wanalyzer-malloc-leak]: leak of ‘rec’
xwayland-24.1.6/redhat-linux-build/../Xext/xselinux_label.c:133:1: enter_function: entry to ‘SELinuxAtomToSID’
xwayland-24.1.6/redhat-linux-build/../Xext/xselinux_label.c:141:15: acquire_memory: allocated here
xwayland-24.1.6/redhat-linux-build/../Xext/xselinux_label.c:69:12: branch_true: following ‘true’ branch...
xwayland-24.1.6/redhat-linux-build/../Xext/xselinux_label.c:142:13: danger: ‘rec’ leaks here; was allocated at [(2)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/1)
# 140| if (!rec) {
# 141| rec = calloc(1, sizeof(SELinuxAtomRec));
# 142|-> if (!rec || !SELinuxArraySet(&arr_atoms, atom, rec))
# 143| return BadAlloc;
# 144| }
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 21cbc56c43)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2076>
This commit is contained in:
parent
161c725991
commit
5b2933abf0
1 changed files with 5 additions and 1 deletions
|
|
@ -139,8 +139,12 @@ SELinuxAtomToSID(Atom atom, int prop, SELinuxObjectRec ** obj_rtn)
|
|||
rec = SELinuxArrayGet(&arr_atoms, atom);
|
||||
if (!rec) {
|
||||
rec = calloc(1, sizeof(SELinuxAtomRec));
|
||||
if (!rec || !SELinuxArraySet(&arr_atoms, atom, rec))
|
||||
if (!rec)
|
||||
return BadAlloc;
|
||||
if (!SELinuxArraySet(&arr_atoms, atom, rec)) {
|
||||
free(rec);
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
|
||||
if (prop) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue