From ca726abe1e4a2522b24e5143c5faf0e594a4802a Mon Sep 17 00:00:00 2001 From: reed Date: Mon, 22 Feb 2016 12:50:25 -0800 Subject: fix misc asserts and checks found by fuzzer BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1719993002 Review URL: https://codereview.chromium.org/1719993002 --- include/core/SkPathEffect.h | 16 ++++++++++++++-- include/effects/Sk1DPathEffect.h | 6 ++---- include/effects/SkAlphaThresholdFilter.h | 4 ++-- include/effects/SkDashPathEffect.h | 7 +++---- 4 files changed, 21 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h index bd68c8fa72..a77b9467e4 100644 --- a/include/core/SkPathEffect.h +++ b/include/core/SkPathEffect.h @@ -183,7 +183,13 @@ public: The reference counts for outer and inner are both incremented in the constructor, and decremented in the destructor. */ - static SkComposePathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) { + static SkPathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) { + if (!outer) { + return SkSafeRef(inner); + } + if (!inner) { + return SkSafeRef(outer); + } return new SkComposePathEffect(outer, inner); } @@ -220,7 +226,13 @@ public: The reference counts for first and second are both incremented in the constructor, and decremented in the destructor. */ - static SkSumPathEffect* Create(SkPathEffect* first, SkPathEffect* second) { + static SkPathEffect* Create(SkPathEffect* first, SkPathEffect* second) { + if (!first) { + return SkSafeRef(second); + } + if (!second) { + return SkSafeRef(first); + } return new SkSumPathEffect(first, second); } diff --git a/include/effects/Sk1DPathEffect.h b/include/effects/Sk1DPathEffect.h index 3419dc23b7..03c6966943 100644 --- a/include/effects/Sk1DPathEffect.h +++ b/include/effects/Sk1DPathEffect.h @@ -46,7 +46,7 @@ public: kRotate_Style, // rotate the shape about its center kMorph_Style, // transform each point, and turn lines into curves - kStyleCount + kLastEnum_Style = kMorph_Style, }; /** Dash by replicating the specified path. @@ -56,9 +56,7 @@ public: @param style how to transform path at each point (based on the current position and tangent) */ - static SkPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase, Style style) { - return new SkPath1DPathEffect(path, advance, phase, style); - } + static SkPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase, Style); virtual bool filterPath(SkPath*, const SkPath&, SkStrokeRec*, const SkRect*) const override; diff --git a/include/effects/SkAlphaThresholdFilter.h b/include/effects/SkAlphaThresholdFilter.h index 17521b6455..033e8d1e54 100644 --- a/include/effects/SkAlphaThresholdFilter.h +++ b/include/effects/SkAlphaThresholdFilter.h @@ -20,8 +20,8 @@ public: * The 0,0 point of the region corresponds to the upper left corner of the * source image. */ - static SkImageFilter* Create(const SkRegion& region, SkScalar innerThreshold, - SkScalar outerThreshold, SkImageFilter* input = NULL); + static SkImageFilter* Create(const SkRegion& region, SkScalar innerMin, + SkScalar outerMax, SkImageFilter* input = NULL); SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP(); }; diff --git a/include/effects/SkDashPathEffect.h b/include/effects/SkDashPathEffect.h index 3c1407b725..08b0a4693f 100644 --- a/include/effects/SkDashPathEffect.h +++ b/include/effects/SkDashPathEffect.h @@ -36,10 +36,7 @@ public: Note: only affects stroked paths. */ - static SkPathEffect* Create(const SkScalar intervals[], int count, SkScalar phase) { - return new SkDashPathEffect(intervals, count, phase); - } - virtual ~SkDashPathEffect(); + static SkPathEffect* Create(const SkScalar intervals[], int count, SkScalar phase); virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override; @@ -58,6 +55,7 @@ public: #endif protected: + virtual ~SkDashPathEffect(); SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase); void flatten(SkWriteBuffer&) const override; @@ -66,6 +64,7 @@ private: int32_t fCount; SkScalar fPhase; // computed from phase + SkScalar fInitialDashLength; int32_t fInitialDashIndex; SkScalar fIntervalLength; -- cgit v1.2.3