From fa4c20e728c2b25f7b1a7d858adc8156005ec229 Mon Sep 17 00:00:00 2001 From: caryclark Date: Mon, 21 Mar 2016 11:25:42 -0700 Subject: [PATCH] exit computeFilters if filter width is zero The fuzzer associated with this bug triggered an assert when building the resize filter. I can't tell if there is a more fundemental bug here or not. Checking for a zero-sized filter fixes the fuzzer. R=fmalita@chromium.org BUG=595856 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1810333002 Review URL: https://codereview.chromium.org/1810333002 --- src/core/SkBitmapScaler.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/SkBitmapScaler.cpp b/src/core/SkBitmapScaler.cpp index c69ac2a950..e3face8c75 100644 --- a/src/core/SkBitmapScaler.cpp +++ b/src/core/SkBitmapScaler.cpp @@ -167,7 +167,10 @@ void SkResizeFilter::computeFilters(int srcSize, // is at (2.5, 2.5). float destFilterDist = (srcBegin + 0.5f - srcPixel) * clampedScale; int filterCount = SkScalarTruncToInt(srcEnd - srcBegin) + 1; - SkASSERT(filterCount > 0); + if (filterCount <= 0) { + // true when srcSize is equal to srcPixel - srcSupport; this may be a bug + return; + } filterValuesArray.reset(filterCount); float filterSum = fBitmapFilter->evaluate_n(destFilterDist, clampedScale, filterCount, filterValuesArray.begin());