From 7dc8531548cc9573e28bb04363dcbb3af5864c9a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 19 Aug 2007 20:28:05 -0700 Subject: [PATCH] Ref count cursors used in hw/xfree86/modes code. The multi-crtc cursor code in hw/xfree86/modes holds a reference to the current cursor. This reference must be correctly ref counted so the cursor is not freed out from underneath this code. --- hw/xfree86/modes/xf86Cursors.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c index 396bf3091..92b90a9d4 100644 --- a/hw/xfree86/modes/xf86Cursors.c +++ b/hw/xfree86/modes/xf86Cursors.c @@ -447,7 +447,10 @@ xf86_use_hw_cursor (ScreenPtr screen, CursorPtr cursor) xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + if (xf86_config->cursor) + FreeCursor (xf86_config->cursor, None); xf86_config->cursor = cursor; + ++cursor->refcnt; if (cursor->bits->width > cursor_info->MaxWidth || cursor->bits->height> cursor_info->MaxHeight) @@ -463,7 +466,10 @@ xf86_use_hw_cursor_argb (ScreenPtr screen, CursorPtr cursor) xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); xf86CursorInfoPtr cursor_info = xf86_config->cursor_info; + if (xf86_config->cursor) + FreeCursor (xf86_config->cursor, None); xf86_config->cursor = cursor; + ++cursor->refcnt; /* Make sure ARGB support is available */ if ((cursor_info->Flags & HARDWARE_CURSOR_ARGB) == 0) @@ -632,4 +638,9 @@ xf86_cursors_fini (ScreenPtr screen) xfree (xf86_config->cursor_image); xf86_config->cursor_image = NULL; } + if (xf86_config->cursor) + { + FreeCursor (xf86_config->cursor, None); + xf86_config->cursor = NULL; + } }