Commit 8c660ccb6f20a34e5a9b758cd2f2f6d41d7259df

Sylvain 2022-01-25T17:14:01

Fixed bug #5256: X11 Segmentation fault with multiple windows and renderers First window is created and it triggers and 'EnterNotify' event which calls SDL_SetMouseFocus() and X11_ShowCursor() while the second windows hasn't finished to be created (eg window->driverdata isn't set) Just check for a valid 'driverdata'

diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c
index 033df8d..9eb1ddd 100644
--- a/src/video/x11/SDL_x11mouse.c
+++ b/src/video/x11/SDL_x11mouse.c
@@ -294,14 +294,15 @@ X11_ShowCursor(SDL_Cursor * cursor)
         SDL_VideoDevice *video = SDL_GetVideoDevice();
         Display *display = GetDisplay();
         SDL_Window *window;
-        SDL_WindowData *data;
 
         for (window = video->windows; window; window = window->next) {
-            data = (SDL_WindowData *)window->driverdata;
-            if (x11_cursor != None) {
-                X11_XDefineCursor(display, data->xwindow, x11_cursor);
-            } else {
-                X11_XUndefineCursor(display, data->xwindow);
+            SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
+            if (data) {
+                if (x11_cursor != None) {
+                    X11_XDefineCursor(display, data->xwindow, x11_cursor);
+                } else {
+                    X11_XUndefineCursor(display, data->xwindow);
+                }
             }
         }
         X11_XFlush(display);