[libpng17] Combine tests for info_ptr==NULL in png_handle_PLTE().

This commit is contained in:
Glenn Randers-Pehrson
2015-12-11 14:28:54 -06:00
parent 454408799b
commit 69f21bc6eb

View File

@@ -853,6 +853,9 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr)
png_debug(1, "in png_handle_PLTE"); png_debug(1, "in png_handle_PLTE");
if (info_ptr == NULL)
return;
if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR))
{ {
png_handle_error(png_ptr, "ignored in grayscale PNG"); png_handle_error(png_ptr, "ignored in grayscale PNG");
@@ -962,15 +965,13 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr)
*/ */
#ifdef PNG_READ_tRNS_SUPPORTED #ifdef PNG_READ_tRNS_SUPPORTED
if (png_ptr->num_trans > 0 || if (png_ptr->num_trans > 0 ||
(info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0)) (info_ptr->valid & PNG_INFO_tRNS) != 0)
{ {
/* Cancel this because otherwise it would be used if the transforms /* Cancel this because otherwise it would be used if the transforms
* require it. Don't cancel the 'valid' flag because this would prevent * require it. Don't cancel the 'valid' flag because this would prevent
* detection of duplicate chunks. * detection of duplicate chunks.
*/ */
png_ptr->num_trans = 0; png_ptr->num_trans = 0;
if (info_ptr != NULL)
info_ptr->num_trans = 0; info_ptr->num_trans = 0;
png_chunk_benign_error(png_ptr, "tRNS must be after"); png_chunk_benign_error(png_ptr, "tRNS must be after");
@@ -978,12 +979,12 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr)
#endif /* READ_tRNS */ #endif /* READ_tRNS */
#ifdef PNG_READ_hIST_SUPPORTED #ifdef PNG_READ_hIST_SUPPORTED
if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) != 0) if ((info_ptr->valid & PNG_INFO_hIST) != 0)
png_chunk_benign_error(png_ptr, "hIST must be after"); png_chunk_benign_error(png_ptr, "hIST must be after");
#endif /* READ_hIST */ #endif /* READ_hIST */
#ifdef PNG_READ_bKGD_SUPPORTED #ifdef PNG_READ_bKGD_SUPPORTED
if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0) if ((info_ptr->valid & PNG_INFO_bKGD) != 0)
png_chunk_benign_error(png_ptr, "bKGD must be after"); png_chunk_benign_error(png_ptr, "bKGD must be after");
#endif /* READ_bKGD */ #endif /* READ_bKGD */
} }