From 3ff8d9d3b1d3fec83cb4ba20ff40fefb97ec2dde Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Thu, 26 Aug 2021 13:37:52 -0300 Subject: [PATCH] Fix issue with png_get_tRNS This fixes an oversight where the return value of png_get_tRNS was being ignored. --- src/r_picformats.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/r_picformats.c b/src/r_picformats.c index 59b1d16c5..5c81d1e02 100644 --- a/src/r_picformats.c +++ b/src/r_picformats.c @@ -901,9 +901,8 @@ static png_bytep *PNG_Read( png_colorp palette; int palette_size; - png_bytep trans; - int trans_num; - png_color_16p trans_values; + png_bytep trans = NULL; + int num_trans = 0; #ifdef PNG_SETJMP_SUPPORTED #ifdef USE_FAR_KEYWORD @@ -998,12 +997,12 @@ static png_bytep *PNG_Read( // color is present on the image, the palette flag is disabled. if (usepal) { - png_get_tRNS(png_ptr, png_info_ptr, &trans, &trans_num, &trans_values); + png_uint_32 result = png_get_tRNS(png_ptr, png_info_ptr, &trans, &num_trans, NULL); - if (trans && trans_num > 0) + if ((result & PNG_INFO_tRNS) && num_trans > 0 && trans != NULL) { INT32 i; - for (i = 0; i < trans_num; i++) + for (i = 0; i < num_trans; i++) { // libpng will transform this image into RGBA even if // the transparent index does not exist in the image,