harden line2d effect
Suggested by https://fuzzer.skia.org/category/n32_canvas/file/c3JjL2NvcmUvU2tTdHJva2UuY3Bw?
Bug: skia:
Change-Id: I8ec48f844bfa5d063f0ab1bdfe0612ec4673ada3
Reviewed-on: https://skia-review.googlesource.com/129260
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/include/effects/Sk2DPathEffect.h b/include/effects/Sk2DPathEffect.h
index 5b7df35..5ebadab 100644
--- a/include/effects/Sk2DPathEffect.h
+++ b/include/effects/Sk2DPathEffect.h
@@ -56,6 +56,9 @@
class SK_API SkLine2DPathEffect : public Sk2DPathEffect {
public:
static sk_sp<SkPathEffect> Make(SkScalar width, const SkMatrix& matrix) {
+ if (!(width >= 0)) {
+ return nullptr;
+ }
return sk_sp<SkPathEffect>(new SkLine2DPathEffect(width, matrix));
}
@@ -67,7 +70,9 @@
protected:
SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
- : Sk2DPathEffect(matrix), fWidth(width) {}
+ : Sk2DPathEffect(matrix), fWidth(width) {
+ SkASSERT(width >= 0);
+ }
void flatten(SkWriteBuffer&) const override;
void nextSpan(int u, int v, int ucount, SkPath*) const override;