Browse Source

fix crash in Cocoa when SDL_RedrawCursor sends NULL to ShowCursor

Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
Victor Ilyushchenko 5 months ago
parent
commit
544772173f
1 changed files with 7 additions and 5 deletions
  1. 7 5
      src/video/cocoa/SDL_cocoamouse.m

+ 7 - 5
src/video/cocoa/SDL_cocoamouse.m

@@ -275,11 +275,13 @@ static bool Cocoa_ShowCursor(SDL_Cursor *cursor)
         SDL_VideoDevice *device = SDL_GetVideoDevice();
         SDL_VideoDevice *device = SDL_GetVideoDevice();
         SDL_Window *window = (device ? device->windows : NULL);
         SDL_Window *window = (device ? device->windows : NULL);
 
 
-        SDL_CursorData *cdata = cursor->internal;
-        cdata->current_frame = 0;
-        if (cdata->frameTimer) {
-            [cdata->frameTimer invalidate];
-            cdata->frameTimer = nil;
+        if (cursor != NULL) {
+            SDL_CursorData *cdata = cursor->internal;
+            cdata->current_frame = 0;
+            if (cdata->frameTimer) {
+                [cdata->frameTimer invalidate];
+                cdata->frameTimer = nil;
+            }
         }
         }
 
 
         for (; window != NULL; window = window->next) {
         for (; window != NULL; window = window->next) {