Fixed bug 2015 - surface getting leak in SDLTest_ScreenShot function
authorSam Lantinga <slouken@libsdl.org>
Mon, 21 Oct 2013 00:30:05 -0700
changeset 7869 6871ab38d224
parent 7868 f92ba4923dcd
child 7870 3aed2f137788
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
src/test/SDL_test_common.c
--- a/src/test/SDL_test_common.c	Mon Oct 21 00:25:43 2013 -0700
+++ b/src/test/SDL_test_common.c	Mon Oct 21 00:30:05 2013 -0700
@@ -1154,11 +1154,13 @@
     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;
     }
 }