From af6deaffa05ae578d8174b557a5ef4116136f121 Mon Sep 17 00:00:00 2001 From: hui su Date: Tue, 23 May 2017 10:25:38 -0700 Subject: [PATCH] webpinfo: handle alpha flag mismatch Throw a warning for false positive vp8x alpha flag; throw an error for false negative vp8x alpha flag. BUG=webp:330 Change-Id: I3933588c9d6d76ecaf515517f7506dea299af638 --- examples/webpinfo.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/webpinfo.c b/examples/webpinfo.c index 42c53b1f..93308859 100644 --- a/examples/webpinfo.c +++ b/examples/webpinfo.c @@ -998,6 +998,14 @@ static WebPInfoStatus Validate(const WebPInfo* const webp_info) { const int exif = !!(webp_info->feature_flags_ & EXIF_FLAG); const int xmp = !!(webp_info->feature_flags_ & XMP_FLAG); const int animation = !!(webp_info->feature_flags_ & ANIMATION_FLAG); + const int alpha = !!(webp_info->feature_flags_ & ALPHA_FLAG); + if (!alpha && webp_info->has_alpha_) { + LOG_ERROR("Unexpected alpha data detected."); + return WEBP_INFO_PARSE_ERROR; + } + if (alpha && !webp_info->has_alpha_) { + LOG_WARN("Alpha flag is set with no alpha data present."); + } if (iccp && !webp_info->chunk_counts_[CHUNK_ICCP]) { LOG_ERROR("Missing ICCP chunk."); return WEBP_INFO_MISSING_DATA;