mirror of
https://github.com/X11Libre/xserver.git
synced 2026-01-26 14:03:17 +00:00
Xext/xselinux: avoid memory leak in SELinuxAtomToSID()
Reported in https://gitlab.freedesktop.org/xorg/xserver/-/issues/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> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2072>
This commit is contained in:
parent
c45edc0c51
commit
640a9cf51e
@ -137,8 +137,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…
x
Reference in New Issue
Block a user