mirror of
				https://github.com/libsdl-org/SDL.git
				synced 2025-11-04 01:34:38 +00:00 
			
		
		
		
	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
This commit is contained in:
		@@ -1154,11 +1154,13 @@ SDLTest_ScreenShot(SDL_Renderer *renderer)
 | 
				
			|||||||
    if (SDL_RenderReadPixels(renderer, NULL, surface->format->format,
 | 
					    if (SDL_RenderReadPixels(renderer, NULL, surface->format->format,
 | 
				
			||||||
                             surface->pixels, surface->pitch) < 0) {
 | 
					                             surface->pixels, surface->pitch) < 0) {
 | 
				
			||||||
        fprintf(stderr, "Couldn't read screen: %s\n", SDL_GetError());
 | 
					        fprintf(stderr, "Couldn't read screen: %s\n", SDL_GetError());
 | 
				
			||||||
 | 
					        SDL_free(surface);
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (SDL_SaveBMP(surface, "screenshot.bmp") < 0) {
 | 
					    if (SDL_SaveBMP(surface, "screenshot.bmp") < 0) {
 | 
				
			||||||
        fprintf(stderr, "Couldn't save screenshot.bmp: %s\n", SDL_GetError());
 | 
					        fprintf(stderr, "Couldn't save screenshot.bmp: %s\n", SDL_GetError());
 | 
				
			||||||
 | 
					        SDL_free(surface);
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user