From 28ad70c56dcd145a7f72fb0643f3fdff32acdb9b Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Tue, 20 Sep 2011 07:51:02 -0700 Subject: [PATCH] Fix PNG decoding bug some png with palette-based alpha channels were incorrectly treated as alpha-less, causing segfault. Change-Id: I03883590f9539848d5135d359b6f105d2b14329f --- examples/cwebp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/cwebp.c b/examples/cwebp.c index ac52aee6..1d472dfa 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -382,8 +382,10 @@ static int ReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha) { } if (png_get_valid(png, info, PNG_INFO_tRNS)) { png_set_tRNS_to_alpha(png); + has_alpha = 1; + } else { + has_alpha = !!(color_type & PNG_COLOR_MASK_ALPHA); } - has_alpha = !!(color_type & PNG_COLOR_MASK_ALPHA); if (!keep_alpha) { png_set_strip_alpha(png);