diff options
author | Glenn Randers-Pehrson <glennrp at users.sourceforge.net> | 2015-11-05 11:15:48 -0600 |
---|---|---|
committer | Glenn Randers-Pehrson <glennrp at users.sourceforge.net> | 2015-11-05 11:15:48 -0600 |
commit | 216dbf7f7eef5d999f2e3ba054407917098e9f85 (patch) | |
tree | 5b0d46f9f5cebee344a9514f5185de532b876dee | |
parent | e461292c2d55725cccba3c3abc2423b94825b2dd (diff) | |
download | libpng-216dbf7f7eef5d999f2e3ba054407917098e9f85.tar.gz |
[libpng12] Clean up coding style in png_handle_PLTE().
-rw-r--r-- | pngrutil.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/pngrutil.c b/pngrutil.c index bc552ccc0..3fd586266 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -558,18 +558,21 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } } - max_palette_length = (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ? - (1 << png_ptr->bit_depth) : PNG_MAX_PALETTE_LENGTH; - /* The cast is safe because 'length' is less than 3*PNG_MAX_PALETTE_LENGTH */ num = (int)length / 3; - /* If the palette has 256 or fewer entries but is too large for the bit depth, - * we don't issue an error, to preserve the behavior of previous libpng versions. - * We silently truncate the unused extra palette entries here. + /* If the palette has 256 or fewer entries but is too large for the bit + * depth, we don't issue an error, to preserve the behavior of previous + * libpng versions. We silently truncate the unused extra palette entries + * here. */ + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + max_palette_length = (1 << png_ptr->bit_depth); + else + max_palette_length = PNG_MAX_PALETTE_LENGTH; + if (num > max_palette_length) - num = max_palette_length; + num = max_palette_length; #ifdef PNG_POINTER_INDEXING_SUPPORTED for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++) |