summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-05-11 19:10:39 +0300
committerAndrei Karas <akaras@inbox.ru>2017-05-11 19:11:54 +0300
commit105447be78701b25e59d5654e4450fdf2195e45a (patch)
tree32d3733a041f2305cbff4562e2a1410040f58c9f
parent85576f6d4fa83a0151ea08e2684f7babdfcfc707 (diff)
downloadplus-105447be78701b25e59d5654e4450fdf2195e45a.tar.gz
plus-105447be78701b25e59d5654e4450fdf2195e45a.tar.bz2
plus-105447be78701b25e59d5654e4450fdf2195e45a.tar.xz
plus-105447be78701b25e59d5654e4450fdf2195e45a.zip
Fix memory leak in creating screenshorts.
-rw-r--r--src/resources/imagewriter.cpp7
1 files 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<png_infopp>(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<png_infopp>(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<png_infopp>(nullptr));
+ png_destroy_write_struct(&png_ptr,
+ &info_ptr);
if (SDL_MUSTLOCK(surface))
SDL_UnlockSurface(surface);