changeset 1945:80d67f0e8567

Better fix for the PNG reader memory leak.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 29 Jun 2018 02:02:42 +0300
parents d9a0a4bccf5d
children c30dfd5e3227
files tools/libgfx.c
diffstat 1 files changed, 1 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tools/libgfx.c	Fri Jun 29 01:56:20 2018 +0300
+++ b/tools/libgfx.c	Fri Jun 29 02:02:42 2018 +0300
@@ -704,6 +704,7 @@
     png_read_image(png_ptr, row_pointers);
 
     png_read_end(png_ptr, NULL);
+    png_free(png_ptr, row_pointers);
 
     // Create palette
     switch (color_type)
@@ -761,9 +762,6 @@
     }
 
 error:
-    if (png_ptr != NULL && row_pointers != NULL)
-        png_free(png_ptr, row_pointers);
-
     if (png_ptr != NULL && info_ptr != NULL)
         png_destroy_read_struct(&png_ptr, &info_ptr, NULL);