Fix issue with png_get_tRNS

This fixes an oversight where the return value of png_get_tRNS was
being ignored.
This commit is contained in:
Jaime Ita Passos 2021-08-26 13:37:52 -03:00
parent ccc71ddafc
commit 3ff8d9d3b1

View file

@ -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,