mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Avoid conditional directives that break statements in pngrutil.c (Romero
Malaquias)
This commit is contained in:
15
pngwutil.c
15
pngwutil.c
@@ -675,10 +675,9 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
int interlace_type)
|
||||
{
|
||||
png_byte buf[13]; /* Buffer to store the IHDR info */
|
||||
int is_invalid_depth;
|
||||
|
||||
png_debug(1, "in png_write_IHDR");
|
||||
|
||||
int is_invalid_depth;
|
||||
|
||||
/* Check that we have valid input data from the application info */
|
||||
switch (color_type)
|
||||
@@ -728,18 +727,22 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
break;
|
||||
|
||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||
if (bit_depth != 8 && bit_depth != 16)
|
||||
is_invalid_depth = (bit_depth != 8);
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
is_invalid_depth = (is_invalid_depth && bit_depth != 16);
|
||||
#endif
|
||||
if (is_invalid_depth)
|
||||
png_error(png_ptr, "Invalid bit depth for grayscale+alpha image");
|
||||
|
||||
png_ptr->channels = 2;
|
||||
break;
|
||||
|
||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||
is_invalid_depth = (bit_depth != 8);
|
||||
#ifdef PNG_WRITE_16BIT_SUPPORTED
|
||||
if (bit_depth != 8 && bit_depth != 16)
|
||||
#else
|
||||
if (bit_depth != 8)
|
||||
is_invalid_depth = (is_invalid_depth && bit_depth != 16);
|
||||
#endif
|
||||
if (is_invalid_depth)
|
||||
png_error(png_ptr, "Invalid bit depth for RGBA image");
|
||||
|
||||
png_ptr->channels = 4;
|
||||
|
||||
Reference in New Issue
Block a user