From: robertphillips Date: Mon, 27 Jun 2016 19:26:29 +0000 (-0700) Subject: Fix Perlin noise fuzz issue X-Git-Tag: submit/tizen/20180928.044319~129^2~50 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6a16fd33da4e77ced87a46fa346a6095ceea8899;p=platform%2Fupstream%2FlibSkiaSharp.git Fix Perlin noise fuzz issue The main "fix" here was that the assert was checking the un-clamped input value rather than the clamped value. The SkValidatingReadBuffer.cpp change was required to get the reproducing fuzz test case to complete. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2107453002 Review-Url: https://codereview.chromium.org/2107453002 --- diff --git a/src/core/SkValidatingReadBuffer.cpp b/src/core/SkValidatingReadBuffer.cpp index 2779516889..2dd70706db 100644 --- a/src/core/SkValidatingReadBuffer.cpp +++ b/src/core/SkValidatingReadBuffer.cpp @@ -248,7 +248,9 @@ SkFlattenable* SkValidatingReadBuffer::readFlattenable(SkFlattenable::Type type) } SkString* namePtr = fFlattenableDict.find(index); - SkASSERT(namePtr); + if (!namePtr) { + return nullptr; + } name = *namePtr; } diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp index 1400905bfe..2268d4e1d5 100644 --- a/src/effects/SkPerlinNoiseShader.cpp +++ b/src/effects/SkPerlinNoiseShader.cpp @@ -275,12 +275,12 @@ SkPerlinNoiseShader::SkPerlinNoiseShader(SkPerlinNoiseShader::Type type, : fType(type) , fBaseFrequencyX(baseFrequencyX) , fBaseFrequencyY(baseFrequencyY) - , fNumOctaves(numOctaves > 255 ? 255 : numOctaves/*[0,255] octaves allowed*/) + , fNumOctaves(SkTPin(numOctaves, 0, 255)) // [0,255] octaves allowed , fSeed(seed) , fTileSize(nullptr == tileSize ? SkISize::Make(0, 0) : *tileSize) , fStitchTiles(!fTileSize.isEmpty()) { - SkASSERT(numOctaves >= 0 && numOctaves < 256); + SkASSERT(fNumOctaves >= 0 && fNumOctaves < 256); } SkPerlinNoiseShader::~SkPerlinNoiseShader() {