summaryrefslogtreecommitdiff
path: root/pngwutil.c
diff options
context:
space:
mode:
authorGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2017-01-20 14:46:21 -0600
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2017-01-20 14:46:21 -0600
commitf604c74a5f06d939c9940adc8fc481e0a5f96870 (patch)
treef950adf8920f4df623f5f795e396fb05eeb64e09 /pngwutil.c
parentc3f4e5fb1a349d383a056b16e9eec17885d7a337 (diff)
[libpng16] Avoid conditional directives that break statements in pngrutil.c (Romero
Malaquias)
Diffstat (limited to 'pngwutil.c')
-rw-r--r--pngwutil.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/pngwutil.c b/pngwutil.c
index 87d4981f4..0f98d582d 100644
--- a/pngwutil.c
+++ b/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;