Merge branch '7.8'
[mesa.git] / src / gallium / state_trackers / xorg / xorg_crtc.c
index 44f7da0f9604a7982c1c2f0d95b8594097be3a37..7268a79a23d2209472b236f2d9c433faca2f4b91 100644 (file)
@@ -276,7 +276,21 @@ err_bo_destroy:
 static void
 crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
 {
 static void
 crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image)
 {
+    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
     modesettingPtr ms = modesettingPTR(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
     if (ms->screen)
        crtc_load_cursor_argb_ga3d(crtc, image);
 #ifdef HAVE_LIBKMS