SDL: Set an error if a cursor image is too large

From cae27a0ec79a579728cde6a8e5331f05addb1d3c Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 19 Oct 2025 18:24:40 -0700
Subject: [PATCH] Set an error if a cursor image is too large

---
 src/video/windows/SDL_windowsmouse.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c
index eead6d4881fb5..af425464c2755 100644
--- a/src/video/windows/SDL_windowsmouse.c
+++ b/src/video/windows/SDL_windowsmouse.c
@@ -311,9 +311,13 @@ static HCURSOR WIN_CreateAnimatedCursorInternal(SDL_CursorFrameInfo *frames, int
     } else {
         surface = frames[0].surface;
     }
+    if (!surface) {
+        return NULL;
+    }
 
     // Since XP and still as of Win11, Windows cursors have a hard size limit of 256x256.
-    if (!surface || surface->w > 256 || surface->h > 256) {
+    if (surface->w > 256 || surface->h > 256) {
+        SDL_SetError("Cursor images must be <= 256x256");
         return NULL;
     }