From 7c87cf44cfc83d87be87d9a89ddb55394691149a Mon Sep 17 00:00:00 2001 From: msarett Date: Fri, 4 Mar 2016 06:23:20 -0800 Subject: [PATCH] Fix YUV horizontal and vertical sampling checks The should fix crashes while decoding skps. BUG=skia:4991 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1766523002 Review URL: https://codereview.chromium.org/1766523002 --- src/codec/SkJpegCodec.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp index d36051511c..b5780c5581 100644 --- a/src/codec/SkJpegCodec.cpp +++ b/src/codec/SkJpegCodec.cpp @@ -568,10 +568,11 @@ static bool is_yuv_supported(jpeg_decompress_struct* dinfo) { // that of Y would be an extremely difficult change, given that clients // allocate memory as if the size of the Y plane is always the size of the // image. However, this case is very, very rare. - if (!(1 == dinfo->comp_info[1].h_samp_factor) && - (1 == dinfo->comp_info[1].v_samp_factor) && - (1 == dinfo->comp_info[2].h_samp_factor) && - (1 == dinfo->comp_info[2].v_samp_factor)) { + if ((1 != dinfo->comp_info[1].h_samp_factor) || + (1 != dinfo->comp_info[1].v_samp_factor) || + (1 != dinfo->comp_info[2].h_samp_factor) || + (1 != dinfo->comp_info[2].v_samp_factor)) + { return false; } -- 2.34.1