Commit 0387bf821ad96f57b4a22790bd1d163b85a2cb2b

Sam Lantinga 2022-03-17T17:55:28

Fixed memory leak in WIN_CreateBlankCursor()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c
index 19977e2..d1f7e41 100644
--- a/src/video/windows/SDL_windowsmouse.c
+++ b/src/video/windows/SDL_windowsmouse.c
@@ -175,11 +175,13 @@ WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
 static SDL_Cursor *
 WIN_CreateBlankCursor()
 {
+    SDL_Cursor *cursor = NULL;
     SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, 32, 32, 32, SDL_PIXELFORMAT_ARGB8888);
     if (surface) {
-        return WIN_CreateCursor(surface, 0, 0);
+        cursor = WIN_CreateCursor(surface, 0, 0);
+        SDL_FreeSurface(surface);
     }
-    return NULL;
+    return cursor;
 }
 
 static SDL_Cursor *