mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
miext: damage: protect against NULL screen priv or funcs
Protect against SEGFAULT in cases where per-screen damage private hasn't been initialized yet or already destroyed, or function pointers not implemented. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
@@ -1714,7 +1714,8 @@ DamageCreate(DamageReportFunc damageReport,
|
||||
pDamage->damageDestroy = damageDestroy;
|
||||
pDamage->pScreen = pScreen;
|
||||
|
||||
(*pScrPriv->funcs.Create) (pDamage);
|
||||
if (pScrPriv && pScrPriv->funcs.Create)
|
||||
pScrPriv->funcs.Create(pDamage);
|
||||
|
||||
return pDamage;
|
||||
}
|
||||
@@ -1755,7 +1756,8 @@ DamageRegister(DrawablePtr pDrawable, DamagePtr pDamage)
|
||||
pDamage->isWindow = FALSE;
|
||||
pDamage->pDrawable = pDrawable;
|
||||
damageInsertDamage(getDrawableDamageRef(pDrawable), pDamage);
|
||||
(*pScrPriv->funcs.Register) (pDrawable, pDamage);
|
||||
if (pScrPriv && pScrPriv->funcs.Register)
|
||||
pScrPriv->funcs.Register(pDrawable, pDamage);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1774,7 +1776,10 @@ DamageUnregister(DamagePtr pDamage)
|
||||
|
||||
damageScrPriv(pScreen);
|
||||
|
||||
(*pScrPriv->funcs.Unregister) (pDrawable, pDamage);
|
||||
if (pScrPriv && pScrPriv->funcs.Unregister)
|
||||
pScrPriv->funcs.Unregister(pDrawable, pDamage);
|
||||
else
|
||||
miDamageUnregister(pDrawable, pDamage);
|
||||
|
||||
if (pDrawable->type == DRAWABLE_WINDOW) {
|
||||
WindowPtr pWindow = (WindowPtr) pDrawable;
|
||||
@@ -1817,7 +1822,9 @@ DamageDestroy(DamagePtr pDamage)
|
||||
|
||||
if (pDamage->damageDestroy)
|
||||
(*pDamage->damageDestroy) (pDamage, pDamage->closure);
|
||||
(*pScrPriv->funcs.Destroy) (pDamage);
|
||||
|
||||
if (pScrPriv && pScrPriv->funcs.Destroy)
|
||||
pScrPriv->funcs.Destroy(pDamage);
|
||||
RegionUninit(&pDamage->damage);
|
||||
RegionUninit(&pDamage->pendingDamage);
|
||||
free(pDamage);
|
||||
|
||||
Reference in New Issue
Block a user