[libpng17] Made the check for out-of-range values in png_set_tRNS() work on

16-bit platforms.
This commit is contained in:
Glenn Randers-Pehrson
2015-01-07 18:59:10 -06:00
parent 3e04e189d8
commit 56e6741b25
3 changed files with 10 additions and 6 deletions

View File

@@ -987,9 +987,9 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
info_ptr->valid &= ~PNG_INFO_tRNS;
info_ptr->num_trans = 0; /* for png_get_tRNS */
if (trans_color != NULL)
if (trans_color != NULL && info_ptr->bit_depth < 16)
{
int sample_max = (1 << info_ptr->bit_depth);
png_uint_16 sample_max = (1 << info_ptr->bit_depth) - 1;
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
trans_color->gray <= sample_max) ||