Skip to content

Commit

Permalink
Fix wrong bit depth handling issue reported by @msmhrt (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
saitoha committed Feb 1, 2015
1 parent 3b6dd3e commit 02d4901
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions converters/loader.c
Expand Up @@ -311,6 +311,7 @@ load_png(unsigned char *buffer, int size,
{
chunk_t read_chunk;
png_uint_32 bitdepth;
png_uint_32 palette_bitdepth;
png_structp png_ptr;
png_infop info_ptr;
unsigned char **rows = NULL;
Expand Down Expand Up @@ -341,8 +342,8 @@ load_png(unsigned char *buffer, int size,
}
switch (png_get_color_type(png_ptr, info_ptr)) {
case PNG_COLOR_TYPE_PALETTE:
bitdepth = png_get_PLTE(png_ptr, info_ptr, &png_palette, pncolors);
if (ppalette && png_palette && bitdepth == 8 && *pncolors <= reqcolors) {
palette_bitdepth = png_get_PLTE(png_ptr, info_ptr, &png_palette, pncolors);
if (ppalette && png_palette && bitdepth == 8 && palette_bitdepth == 8 && *pncolors <= reqcolors) {
*ppalette = malloc(*pncolors * 3);
if (*ppalette == NULL) {
goto cleanup;
Expand Down

0 comments on commit 02d4901

Please sign in to comment.