Commit 11d38d696e6922bdfb996a58055a80ee2a57d42f

Sam Lantinga 2013-10-21T00:30:05

Fixed bug 2015 - surface getting leak in SDLTest_ScreenShot function Nitz 2013-08-06 03:53:41 UTC In function SDLTest_ScreenShot() surface pointer getting leak while return

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 3bb2f0a..c117a93 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1154,11 +1154,13 @@ SDLTest_ScreenShot(SDL_Renderer *renderer)
     if (SDL_RenderReadPixels(renderer, NULL, surface->format->format,
                              surface->pixels, surface->pitch) < 0) {
         fprintf(stderr, "Couldn't read screen: %s\n", SDL_GetError());
+        SDL_free(surface);
         return;
     }
 
     if (SDL_SaveBMP(surface, "screenshot.bmp") < 0) {
         fprintf(stderr, "Couldn't save screenshot.bmp: %s\n", SDL_GetError());
+        SDL_free(surface);
         return;
     }
 }