mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 10:14:52 +00:00
Xext: sync: protect init_system_idle_counter() from allocation failure
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
18
Xext/sync.c
18
Xext/sync.c
@@ -2818,20 +2818,24 @@ init_system_idle_counter(const char *name, int deviceid)
|
||||
|
||||
IdleTimeQueryValue(NULL, &idle);
|
||||
|
||||
IdleCounterPriv *priv = calloc(1, sizeof(IdleCounterPriv));
|
||||
if (!priv)
|
||||
return NULL;
|
||||
|
||||
idle_time_counter = SyncCreateSystemCounter(name, idle, resolution,
|
||||
XSyncCounterUnrestricted,
|
||||
IdleTimeQueryValue,
|
||||
IdleTimeBracketValues);
|
||||
|
||||
if (idle_time_counter != NULL) {
|
||||
IdleCounterPriv *priv = malloc(sizeof(IdleCounterPriv));
|
||||
|
||||
priv->value_less = priv->value_greater = NULL;
|
||||
priv->deviceid = deviceid;
|
||||
|
||||
idle_time_counter->pSysCounterInfo->private = priv;
|
||||
if (!idle_time_counter) {
|
||||
free(priv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
priv->value_less = priv->value_greater = NULL;
|
||||
priv->deviceid = deviceid;
|
||||
|
||||
idle_time_counter->pSysCounterInfo->private = priv;
|
||||
return idle_time_counter;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user