backends/x11: Only free cursor if it was created successfully

XcursorLibraryLoadCursor can return 'None' if the current cursor theme
is missing the requested icon. If XFreeCursor is then called on this
cursor, it generates a BadCursor error causing gnome-shell to crash.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/254

(cherry picked from commit 1bfa20929b36d06cc23667d1122175149615b56d)
This commit is contained in:
Sebastian Keller 2018-08-02 00:58:56 +02:00 committed by Marco Trevisan (Treviño)
parent abe682efa0
commit f76cacd154

View File

@ -1394,6 +1394,8 @@ meta_screen_update_cursor (MetaScreen *screen)
XDefineCursor (display->xdisplay, screen->xroot, xcursor); XDefineCursor (display->xdisplay, screen->xroot, xcursor);
XFlush (display->xdisplay); XFlush (display->xdisplay);
if (xcursor)
XFreeCursor (display->xdisplay, xcursor); XFreeCursor (display->xdisplay, xcursor);
} }