Commit 881f747d5c8026a6d4f456db60cf11e67ddd1366

Yufei Huang 2021-11-09T13:35:18

Always destroy icon

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c
index 4c3cab1..65263ef 100644
--- a/src/video/windows/SDL_windowsmouse.c
+++ b/src/video/windows/SDL_windowsmouse.c
@@ -154,8 +154,9 @@ WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
     /* The cursor returned by CreateIconIndirect does not respect system cursor size
         preference, use CopyImage to duplicate the cursor with desired sizes */
     hcursor = CopyImage(hicon, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE);
+    DestroyIcon(hicon);
+
     if (!hcursor) {
-        DestroyIcon(hicon);
         WIN_SetError("CopyImage()");
         return NULL;
     }