Xext/sync: avoid null dereference if SysCounterGetPrivate() returns NULL

Reported in https://gitlab.freedesktop.org/xorg/xserver/-/issues/1817:

xwayland-24.1.6/redhat-linux-build/../Xext/sync.c:2664:9: danger: dereference of NULL ‘SysCounterGetPrivate(pCounter)’

xwayland-24.1.6/redhat-linux-build/../Xext/sync.c:2677:14: danger: dereference of NULL ‘SysCounterGetPrivate(pCounter)’

xwayland-24.1.6/redhat-linux-build/../Xext/sync.c:2767:14: danger: dereference of NULL ‘SysCounterGetPrivate(pCounter)’

xwayland-24.1.6/redhat-linux-build/../Xext/sync.c:2800:14: danger: dereference of NULL ‘SysCounterGetPrivate(pCounter)’

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:
Alan Coopersmith
2025-10-11 20:59:49 +03:00
committed by Enrico Weigelt
parent c046c7629e
commit 446baf6b15

View File

@@ -2424,8 +2424,7 @@ IdleTimeBlockHandler(void *pCounter, void *wt)
{
SyncCounter *counter = pCounter;
IdleCounterPriv *priv = SysCounterGetPrivate(counter);
if (!priv)
return;
BUG_RETURN(priv == NULL);
int64_t *less = priv->value_less;
int64_t *greater = priv->value_greater;
int64_t idle, old_idle;
@@ -2516,8 +2515,7 @@ IdleTimeWakeupHandler(void *pCounter, int rc)
{
SyncCounter *counter = pCounter;
IdleCounterPriv *priv = SysCounterGetPrivate(counter);
if (!priv)
return;
BUG_RETURN(priv == NULL);
int64_t *less = priv->value_less;
int64_t *greater = priv->value_greater;
int64_t idle;
@@ -2551,8 +2549,7 @@ IdleTimeBracketValues(void *pCounter, int64_t *pbracket_less,
{
SyncCounter *counter = pCounter;
IdleCounterPriv *priv = SysCounterGetPrivate(counter);
if (!priv)
return;
BUG_RETURN(priv == NULL);
int64_t *less = priv->value_less;
int64_t *greater = priv->value_greater;
Bool registered = (less || greater);