xfree86: Take second reference for SavedCursor in xf86CursorSetCursor

The same pointer is kept in CurrentCursor as well, therefore two
RefCursor calls are needed.

Fixes use-after-free after switching VTs.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1067
This commit is contained in:
Michel Dänzer 2020-08-31 12:10:43 +02:00 committed by Michel Dänzer
parent 2902b78535
commit 919f1f46fc
1 changed files with 3 additions and 0 deletions

View File

@ -334,6 +334,9 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
ScreenPriv->HotY = cursor->bits->yhot;
if (!infoPtr->pScrn->vtSema) {
cursor = RefCursor(cursor);
if (ScreenPriv->SavedCursor)
FreeCursor(ScreenPriv->SavedCursor, None);
ScreenPriv->SavedCursor = cursor;
return;
}