diff options
author | Yuqian Li <liyuqian@google.com> | 2018-05-14 09:39:24 -0700 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-14 18:27:09 +0000 |
commit | 45a6d7159e7c5a03c4191610ff981dd7fc2be7b4 (patch) | |
tree | 0e51a7ff0c0f251adfac149a6cc62d9b60776f32 /src/shaders/gradients | |
parent | 9236b02264d4b15208be3b8b8919f4ed441a3c85 (diff) |
Avoid dividing by zero in SkTwoPointConicalGradient::Create
Bug: oss-fuzz:6146 oss-fuzz:7474
Change-Id: I5f0488f4572140ccb7b9374bc9a66b8ae81dd2d4
Reviewed-on: https://skia-review.googlesource.com/127990
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: Yuqian Li <liyuqian@google.com>
Diffstat (limited to 'src/shaders/gradients')
-rw-r--r-- | src/shaders/gradients/SkTwoPointConicalGradient.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/shaders/gradients/SkTwoPointConicalGradient.cpp b/src/shaders/gradients/SkTwoPointConicalGradient.cpp index 48877da34c..d98f4bce20 100644 --- a/src/shaders/gradients/SkTwoPointConicalGradient.cpp +++ b/src/shaders/gradients/SkTwoPointConicalGradient.cpp @@ -54,6 +54,9 @@ sk_sp<SkShader> SkTwoPointConicalGradient::Create(const SkPoint& c0, SkScalar r0 Type gradientType; if (SkScalarNearlyZero((c0 - c1).length())) { + if (SkScalarNearlyZero(SkTMax(r0, r1))) { + return nullptr; // Degenerate case; avoid dividing by zero. + } // Concentric case: we can pretend we're radial (with a tiny twist). const SkScalar scale = sk_ieee_float_divide(1, SkTMax(r0, r1)); gradientMatrix = SkMatrix::MakeTrans(-c1.x(), -c1.y()); |