8031352: Enhance PNG handling

Reviewed-by: prr, mschoene
This commit is contained in:
Sergey Bylokhov 2014-01-21 06:45:46 +04:00
parent 60a88657a7
commit 92a7e2b415
2 changed files with 14 additions and 0 deletions

View File

@ -1862,6 +1862,9 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
info_ptr->bit_depth = 8;
info_ptr->num_trans = 0;
if (png_ptr->palette == NULL)
png_error (png_ptr, "Palette is NULL in indexed image");
}
else
{

View File

@ -512,6 +512,17 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
}
}
if ((num_palette > 0 && palette == NULL) ||
(num_palette == 0
# ifdef PNG_MNG_FEATURES_SUPPORTED
&& (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0
# endif
))
{
png_error(png_ptr, "Invalid palette");
return;
}
/* It may not actually be necessary to set png_ptr->palette here;
* we do it for backward compatibility with the way the png_handle_tRNS
* function used to do the allocation.