summaryrefslogtreecommitdiff
path: root/pngwutil.c
diff options
context:
space:
mode:
authorRomero B. de S. Malaquias <romero.malaquias@gmail.com>2017-01-20 16:31:54 -0300
committerGitHub <noreply@github.com>2017-01-20 16:31:54 -0300
commitc3f4e5fb1a349d383a056b16e9eec17885d7a337 (patch)
tree55e0af904eb0a322a49edb9b2ccfd9ae70cb240b /pngwutil.c
parentae794eefaa2753a11faccd8850d56d545cf887f7 (diff)
downloadlibpng-c3f4e5fb1a349d383a056b16e9eec17885d7a337.tar.gz
Avoiding conditional directives that break statements
Diffstat (limited to 'pngwutil.c')
-rw-r--r--pngwutil.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/pngwutil.c b/pngwutil.c
index d1a82d45e..87d4981f4 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -677,6 +677,8 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
png_byte buf[13]; /* Buffer to store the IHDR info */
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)
@@ -700,11 +702,11 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,
break;
case PNG_COLOR_TYPE_RGB:
+ 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 RGB image");
png_ptr->channels = 3;