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:
parent
a7f8d0db3d
commit
746648be85
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue