shithub: choc

Download patch

ref: 9c2e7100d03892ca84959832e17c9a40d52048d1
parent: c00d374d689c3d7437b1ad55fbd23f9e20f60e5c
author: turol <turol@users.noreply.github.com>
date: Sat Aug 12 21:55:50 EDT 2017

video: Fix resource leak on PNG saving failure paths (#933)


--- a/src/v_video.c
+++ b/src/v_video.c
@@ -750,6 +750,7 @@
                                    error_fn, warning_fn);
     if (!ppng)
     {
+        fclose(handle);
         return;
     }
 
@@ -756,6 +757,7 @@
     pinfo = png_create_info_struct(ppng);
     if (!pinfo)
     {
+        fclose(handle);
         png_destroy_write_struct(&ppng, NULL);
         return;
     }
@@ -769,6 +771,7 @@
     pcolor = malloc(sizeof(*pcolor) * 256);
     if (!pcolor)
     {
+        fclose(handle);
         png_destroy_write_struct(&ppng, &pinfo);
         return;
     }