aboutsummaryrefslogtreecommitdiff
path: root/image
diff options
context:
space:
mode:
authorEugene Sandulenko2020-01-06 13:35:04 +0100
committerEugene Sandulenko2020-01-06 13:35:04 +0100
commit6ce6922eef47b4a1a56b7f514937e1cae05ebbd1 (patch)
tree8a0cadbe5434252f6f0b0b8049dc59491f314286 /image
parenta6307b768c1d1771c031cc8061a929b45a3d66ac (diff)
downloadscummvm-rg350-6ce6922eef47b4a1a56b7f514937e1cae05ebbd1.tar.gz
scummvm-rg350-6ce6922eef47b4a1a56b7f514937e1cae05ebbd1.tar.bz2
scummvm-rg350-6ce6922eef47b4a1a56b7f514937e1cae05ebbd1.zip
IMAGE: Fix potential memory leaks
Diffstat (limited to 'image')
-rw-r--r--image/png.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/image/png.cpp b/image/png.cpp
index 1072d41a18..307334a64b 100644
--- a/image/png.cpp
+++ b/image/png.cpp
@@ -283,11 +283,19 @@ bool writePNG(Common::WriteStream &out, const Graphics::Surface &input) {
png_structp pngPtr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!pngPtr) {
+ if (tmp) {
+ tmp->free();
+ delete tmp;
+ }
return false;
}
png_infop infoPtr = png_create_info_struct(pngPtr);
if (!infoPtr) {
png_destroy_write_struct(&pngPtr, NULL);
+ if (tmp) {
+ tmp->free();
+ delete tmp;
+ }
return false;
}