Check return value of png_get_tRNS before using trans

png_get_tRNS may not set pointers if it fails.
This commit is contained in:
James R 2023-02-10 18:37:49 -08:00
parent 1aa9e01419
commit a9469c8ffb

View file

@ -999,9 +999,7 @@ 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);
if (trans && trans_num > 0)
if (png_get_tRNS(png_ptr, png_info_ptr, &trans, &trans_num, &trans_values) == PNG_INFO_tRNS)
{
INT32 i;
for (i = 0; i < trans_num; i++)