summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/xorg/xorg_crtc.c
diff options
context:
space:
mode:
authorMichel Dänzer <daenzer@vmware.com>2010-03-10 18:26:25 +0100
committerMichel Dänzer <daenzer@vmware.com>2010-03-10 18:26:25 +0100
commit766d90f1a201d8fd19e49df14d712efbb82223b4 (patch)
tree5916177ac795c81af6dd6d7d58e1716f804fa058 /src/gallium/state_trackers/xorg/xorg_crtc.c
parentffd625d4aaf145eb28fc76617e95ffc3fdfd54cc (diff)
st/xorg: Work around cursor reference counting bugs in older X servers.
Could result in use of freed memory and consequently random crashes, e.g. on screen resize. (cherry picked from commit 21c91b410a2a2cbf8eb677e59e3322f86320f2b0) Conflicts: src/gallium/state_trackers/xorg/xorg_tracker.h
Diffstat (limited to 'src/gallium/state_trackers/xorg/xorg_crtc.c')
-rw-r--r--src/gallium/state_trackers/xorg/xorg_crtc.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c
index 000ec9048f..53a3c5c2b7 100644
--- a/src/gallium/state_trackers/xorg/xorg_crtc.c
+++ b/src/gallium/state_trackers/xorg/xorg_crtc.c
@@ -275,7 +275,21 @@ err_bo_destroy:
static void
crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
modesettingPtr ms = modesettingPTR(crtc->scrn);
+
+ /* Older X servers have cursor reference counting bugs leading to use of
+ * freed memory and consequently random crashes. Should be fixed as of
+ * xserver 1.8, but this workaround shouldn't hurt anyway.
+ */
+ if (config->cursor)
+ config->cursor->refcnt++;
+
+ if (ms->cursor)
+ FreeCursor(ms->cursor, None);
+
+ ms->cursor = config->cursor;
+
if (ms->screen)
crtc_load_cursor_argb_ga3d(crtc, image);
#ifdef HAVE_LIBKMS