From e72df28c97b8c3ba6a343a0553e1959a7d6df901 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 18 May 2004 06:51:46 +0000 Subject: [PATCH] fix memleak on error --- stepmania/src/RageSurface_Load_PNG.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stepmania/src/RageSurface_Load_PNG.cpp b/stepmania/src/RageSurface_Load_PNG.cpp index bb5e4718cb..053b13bc4b 100644 --- a/stepmania/src/RageSurface_Load_PNG.cpp +++ b/stepmania/src/RageSurface_Load_PNG.cpp @@ -79,9 +79,12 @@ static SDL_Surface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro return NULL; } + SDL_Surface *volatile surf = NULL; if( setjmp(png_jmpbuf(png)) ) { png_destroy_read_struct( &png, &info_ptr, png_infopp_NULL ); + if( surf ) + SDL_FreeSurface( surf ); return NULL; } @@ -181,7 +184,6 @@ static SDL_Surface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro png_read_update_info( png, info_ptr ); - SDL_Surface *surf; switch( type ) { case PALETTE: