Fix cursor ref counting mistakes with sprites and xf86Cursor.c
A few cursor value assignments weren't getting correctly ref counted, causing leaks of cursor objects. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
a80b1f888f
commit
cdeb2c23f8
|
@ -851,6 +851,8 @@ CloseDevice(DeviceIntPtr dev)
|
|||
}
|
||||
|
||||
if (DevHasCursor(dev) && dev->spriteInfo->sprite) {
|
||||
if (dev->spriteInfo->sprite->current)
|
||||
FreeCursor(dev->spriteInfo->sprite->current, None);
|
||||
xfree(dev->spriteInfo->sprite->spriteTrace);
|
||||
xfree(dev->spriteInfo->sprite);
|
||||
}
|
||||
|
|
20
dix/events.c
20
dix/events.c
|
@ -2932,6 +2932,7 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
|
|||
{
|
||||
SpritePtr pSprite;
|
||||
ScreenPtr pScreen;
|
||||
CursorPtr pCursor;
|
||||
|
||||
if (!pDev->spriteInfo->sprite)
|
||||
{
|
||||
|
@ -2975,8 +2976,7 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
|
|||
|
||||
if (pWin)
|
||||
{
|
||||
pSprite->current = wCursor(pWin);
|
||||
pSprite->current->refcnt++;
|
||||
pCursor = wCursor(pWin);
|
||||
pSprite->spriteTrace = (WindowPtr *)xcalloc(1, 32*sizeof(WindowPtr));
|
||||
if (!pSprite->spriteTrace)
|
||||
FatalError("Failed to allocate spriteTrace");
|
||||
|
@ -2989,13 +2989,18 @@ InitializeSprite(DeviceIntPtr pDev, WindowPtr pWin)
|
|||
pSprite->pDequeueScreen = pSprite->pEnqueueScreen;
|
||||
|
||||
} else {
|
||||
pSprite->current = NullCursor;
|
||||
pCursor = NullCursor;
|
||||
pSprite->spriteTrace = NULL;
|
||||
pSprite->spriteTraceSize = 0;
|
||||
pSprite->spriteTraceGood = 0;
|
||||
pSprite->pEnqueueScreen = screenInfo.screens[0];
|
||||
pSprite->pDequeueScreen = pSprite->pEnqueueScreen;
|
||||
}
|
||||
if (pCursor)
|
||||
pCursor->refcnt++;
|
||||
if (pSprite->current)
|
||||
FreeCursor(pSprite->current, None);
|
||||
pSprite->current = pCursor;
|
||||
|
||||
if (pScreen)
|
||||
{
|
||||
|
@ -3048,6 +3053,7 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen)
|
|||
{
|
||||
SpritePtr pSprite = NULL;
|
||||
WindowPtr win = NULL;
|
||||
CursorPtr pCursor;
|
||||
if (!pScreen)
|
||||
return ;
|
||||
|
||||
|
@ -3063,8 +3069,12 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen)
|
|||
pSprite->hotLimits.x2 = pScreen->width;
|
||||
pSprite->hotLimits.y2 = pScreen->height;
|
||||
pSprite->win = win;
|
||||
pSprite->current = wCursor (win);
|
||||
pSprite->current->refcnt++;
|
||||
pCursor = wCursor(win);
|
||||
if (pCursor)
|
||||
pCursor->refcnt++;
|
||||
if (pSprite->current)
|
||||
FreeCursor(pSprite->current, 0);
|
||||
pSprite->current = pCursor;
|
||||
pSprite->spriteTraceGood = 1;
|
||||
pSprite->spriteTrace[0] = win;
|
||||
(*pScreen->CursorLimits) (pDev,
|
||||
|
|
|
@ -312,6 +312,8 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
|
|||
xf86SetCursor(pScreen, NullCursor, x, y);
|
||||
ScreenPriv->isUp = FALSE;
|
||||
}
|
||||
if (ScreenPriv->CurrentCursor)
|
||||
FreeCursor(ScreenPriv->CurrentCursor, None);
|
||||
ScreenPriv->CurrentCursor = NullCursor;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue