Skip to content

Commit

Permalink
[libpng16] Clean up coding style in png_handle_PLTE()
Browse files Browse the repository at this point in the history
  • Loading branch information
Glenn Randers-Pehrson committed Nov 5, 2015
1 parent 64fef09 commit 83f4c73
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pngrutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,18 +930,21 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
return;
}

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++)
Expand Down

0 comments on commit 83f4c73

Please sign in to comment.