commit 9c2e7100d03892ca84959832e17c9a40d52048d1
Author: turol <turol@users.noreply.github.com>
AuthorDate: Sun Aug 13 01:55:50 2017 +0300
Commit: Simon Howard <fraggle+github@gmail.com>
CommitDate: Sat Aug 12 18:55:50 2017 -0400
video: Fix resource leak on PNG saving failure paths (#933)
---
src/v_video.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/v_video.c b/src/v_video.c
index 7c34fca6..fb06f8fd 100644
--- a/src/v_video.c
+++ b/src/v_video.c
@@ -750,12 +750,14 @@ void WritePNGfile(char *filename, byte *data,
error_fn, warning_fn);
if (!ppng)
{
+ fclose(handle);
return;
}
pinfo = png_create_info_struct(ppng);
if (!pinfo)
{
+ fclose(handle);
png_destroy_write_struct(&ppng, NULL);
return;
}
@@ -769,6 +771,7 @@ void WritePNGfile(char *filename, byte *data,
pcolor = malloc(sizeof(*pcolor) * 256);
if (!pcolor)
{
+ fclose(handle);
png_destroy_write_struct(&ppng, &pinfo);
return;
}