mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2025-12-20 08:10:03 +01:00
Xext/sync: Avoid dereference of invalid pointer if malloc() failed
Reported incorrectly in #1817 as:
xwayland-24.1.6/redhat-linux-build/../Xext/sync.c:2835:33: acquire_memory: allocated here
xwayland-24.1.6/redhat-linux-build/../Xext/sync.c:2843:12: danger: ‘priv’ leaks here; was allocated at [(30)](sarif:/runs/0/results/5/codeFlows/0/threadFlows/0/locations/29)
but the "leak" is really saving the pointer in an uninitalized pointer in
a structure that was already freed when the malloc of the SysCounterInfo
struct failed in SyncCreateSystemCounter(), because it returned the address
of the freed struct instead of NULL to indicate failure.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 6034ce11b6)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2077>
This commit is contained in:
parent
9bad510a45
commit
976ef43f95
1 changed files with 1 additions and 1 deletions
|
|
@ -1004,7 +1004,7 @@ SyncCreateSystemCounter(const char *name,
|
|||
psci = malloc(sizeof(SysCounterInfo));
|
||||
if (!psci) {
|
||||
FreeResource(pCounter->sync.id, RT_NONE);
|
||||
return pCounter;
|
||||
return NULL;
|
||||
}
|
||||
pCounter->pSysCounterInfo = psci;
|
||||
psci->pCounter = pCounter;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue