SDL: fix crash in Cocoa when SDL_RedrawCursor sends NULL to ShowCursor

From 544772173fe4c9e63c66b90929282e8db106fb34 Mon Sep 17 00:00:00 2001
From: Victor Ilyushchenko <[EMAIL REDACTED]>
Date: Mon, 20 Oct 2025 22:21:57 +0300
Subject: [PATCH] fix crash in Cocoa when SDL_RedrawCursor sends NULL to
 ShowCursor

Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
---
 src/video/cocoa/SDL_cocoamouse.m | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m
index b0974a48b2db0..21bae3507e61a 100644
--- a/src/video/cocoa/SDL_cocoamouse.m
+++ b/src/video/cocoa/SDL_cocoamouse.m
@@ -275,11 +275,13 @@ static bool Cocoa_ShowCursor(SDL_Cursor *cursor)
         SDL_VideoDevice *device = SDL_GetVideoDevice();
         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) {