From 105447be78701b25e59d5654e4450fdf2195e45a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 11 May 2017 19:10:39 +0300 Subject: Fix memory leak in creating screenshorts. --- src/resources/imagewriter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp index c8cd89318..b9287cf8a 100644 --- a/src/resources/imagewriter.cpp +++ b/src/resources/imagewriter.cpp @@ -47,7 +47,7 @@ bool ImageWriter::writePNG(SDL_Surface *const surface, return false; } - const png_infop info_ptr = png_create_info_struct(png_ptr); + png_infop info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { png_destroy_write_struct(&png_ptr, static_cast(nullptr)); @@ -57,7 +57,7 @@ bool ImageWriter::writePNG(SDL_Surface *const surface, if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_write_struct(&png_ptr, static_cast(nullptr)); + png_destroy_write_struct(&png_ptr, &info_ptr); reportAlways("problem writing to %s", filename.c_str()); return false; } @@ -107,7 +107,8 @@ bool ImageWriter::writePNG(SDL_Surface *const surface, delete [] row_pointers; - png_destroy_write_struct(&png_ptr, static_cast(nullptr)); + png_destroy_write_struct(&png_ptr, + &info_ptr); if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface); -- cgit v1.2.3-60-g2f50