From b68c393223ed73d81f4c9896c3d6e0e7262243e3 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 28 Jun 2020 00:40:24 -0700 Subject: [PATCH] Util: Fix crash if PNG header fails to write --- CHANGES | 1 + src/util/png-io.c | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 020715b13..2815b229c 100644 --- a/CHANGES +++ b/CHANGES @@ -35,6 +35,7 @@ Other fixes: - Qt: Fix file handle leak on opening an invalid ROM - Qt: Fix a race condition in the frame inspector - Qt: Fix Italian RTC translation (fixes mgba.io/i/1798) + - Util: Fix crash if PNG header fails to write Misc: - Debugger: Keep track of global cycle count - FFmpeg: Add looping option for GIF/APNG diff --git a/src/util/png-io.c b/src/util/png-io.c index 1dbadc6e1..530ea8f0b 100644 --- a/src/util/png-io.c +++ b/src/util/png-io.c @@ -47,19 +47,16 @@ static png_infop _pngWriteHeader(png_structp png, unsigned width, unsigned heigh return 0; } png_set_IHDR(png, info, width, height, 8, type, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + png_write_info(png, info); return info; } png_infop PNGWriteHeader(png_structp png, unsigned width, unsigned height) { - png_infop info = _pngWriteHeader(png, width, height, PNG_COLOR_TYPE_RGB); - png_write_info(png, info); - return info; + return _pngWriteHeader(png, width, height, PNG_COLOR_TYPE_RGB); } png_infop PNGWriteHeaderA(png_structp png, unsigned width, unsigned height) { - png_infop info = _pngWriteHeader(png, width, height, PNG_COLOR_TYPE_RGB_ALPHA); - png_write_info(png, info); - return info; + return _pngWriteHeader(png, width, height, PNG_COLOR_TYPE_RGB_ALPHA); } png_infop PNGWriteHeader8(png_structp png, unsigned width, unsigned height) {